python - 在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)
但如你所知,它不起作用
解决方案
推荐阅读
- java - 如何使用 JOptionPane 从现有的文本菜单制作 GUI?
- postgresql - 选择最常出现的值 PostgreSQL
- swift - 如何在单个表格视图中显示多个属性?迅速
- node.js - 是否为代理后面的 node.js 推荐 SSL
- random - 在 python 3.5 中使用 random.choices() 的另一种方法是什么
- python - 如何将 Python 函数解耦为单独的进程?
- r - 计算权重为其他两列的两列的加权和
- ios - 打印时自动布局框架 x 位置不正确
- python-3.x - 获取 ImportError:使用 pip3 安装 flask_dance 时无法导入名称“dist”
- bash - 如果文件夹名称在 bash 中以 4 位数字结尾,则递归重命名添加括号