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