code: 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"})
docs: Stream n JSON responses
      ---
      tags:
        - Dynamic data
      parameters:
        - in: path
          name: n
          type: int
      produces:
        - application/json
      responses:
        200:
          description: Streamed JSON responses.