如何 return 多个 json 文件在同一路径烧瓶中?

How to return multiple json file in same route flask?

通过使用 Axios,我可以从 flask 中成功获取一个 JSON 文件 returned。 现在我有另一个 JSON 文件需要传递到同一路径:/dashboard,是否可以在一个路径中 return 多个 JSON 文件?

ps。我是烧瓶新手

代码如下:

    @app.route("/dashboard", methods= ['GET'])
    def key_index():
      try:
        key_index = db.sns.find({},{"_id":0}).sort([("datetime", -1)]).limit(1)
        return dumps(key_index)
      except Exception as e:
        return dumps({'error': str(e)})

   @app.route("/dashboard", methods= ['GET'])
   def sns_trend():
     try:
       trend = db.sns_2.find({})
       return dumps(trend)
     except Exception as e:
       return dumps({'error': str(e)})

一个字母json可以return2条数据 例子

  @app.route("/dashboard", methods= ['GET'])
    def key_index():
      try:
        key_index = db.sns.find({},{"_id":0}).sort([("datetime", -1)]).limit(1)
        trend = db.sns_2.find({})
        return dumps({
            'key_index':key_index,
             'trend':trend
          })
      except Exception as e:
        return dumps({'error': str(e)})