首页 > 解决方案 > 在GET请求调用flask上运行js文件/协程

问题描述

嗨,我如何在烧瓶中运行 GET 请求的脚本文件?

我在 aiohttp 中的代码如下所示

async def javascript(request):
    content = open(os.path.join(ROOT, "streaming.js"), "r").read()
    return web.Response(content_type="application/javascript", text=content)

我添加的是

@app.route('/streaming', methods=['GET'])
async def javascript()
    content = open(os.path.join(ROOT, "streaming.js"), "r").read()
    return Response(content_type="application/javascript", text=content)

但如你所知,它不起作用

标签: pythonflaskflask-restfulaiohttp

解决方案


推荐阅读