python - Flask url 重定向给出了意外的关键字参数异常
问题描述
我正在尝试使用烧瓶根据 URL 参数连接到不同的数据库
在将路线定义为
@app.route('/data_service/file/<string:db>/', methods=['GET','DELETE','POST','PUT'])
def file():
然而,烧瓶抱怨说
TypeError: file() got an unexpected keyword argument 'db'
恕我直言,这应该根据描述工作,例如https://pythonprogramming.net/flask-url-converters-tutorial/
解决方案
我发现了错误
参数应该出现在函数中,在这种情况下,代码应该是
@app.route('/data_service/file/<string:db>/', methods=['GET','DELETE','POST','PUT'])
def file():
推荐阅读
- vim - 在 vim 中安装插件
- sql - 如何在不使用窗口函数的情况下解决这个 sql 问题
- user-interface - Dat.GUI 中的随机化值
- react-native - 我如何在标题 react-native 中的按钮周围更改背景颜色
- postgresql - psql:无法连接到服务器:连接被拒绝
- scala - Scala中的堆栈修改特征不起作用
- linux - 将 Zabbix Graph 数据集成到 Itop Server Info 中
- python - 我想将 .py 编译为 .exe
- javascript - NestJS 依赖注入错误:提供程序/模块不是当前处理模块的一部分
- flutter - 警报对话框颤振错误仅有效值 0:1