@app.route('/stream/<int:n>')
def stream_n_messages(n):
 response = get_dict('url', 'args', 'headers', 'origin')
 n = min(n, 100)
 def generate_stream():
  for i in range(n):
   response['id'] = i
   (yield (json.dumps(response) + '\n'))
 return Response(generate_stream(), headers={'Content-Type': 'application/json'})

@ app . route ( '/stream/<int:n>' ) def stream_n_messages ( n ) : response = get_dict ( 'url' , 'args' , 'headers' , 'origin' ) n = min ( n , 100 ) def generate_stream ( ) : for i in range ( n ) : response [ 'id' ] = i ( yield ( json . dumps ( response ) + '\n' ) ) return Response ( generate_stream ( ) , headers = { 'Content-Type' : 'application/json' } )
stream n json messages .