Flask URL重定向提供了意外的关键字参数异常

时间:2019-10-30 18:23:27

标签: python flask

我正在尝试使用flask连接到基于URL参数的其他数据库

将路线定义为

@app.route('/data_service/file/<string:db>/', methods=['GET','DELETE','POST','PUT'])
def file():

但是,烧瓶抱怨说

TypeError: file() got an unexpected keyword argument 'db'

Imho这应该根据说明进行操作,例如https://pythonprogramming.net/flask-url-converters-tutorial/

1 个答案:

答案 0 :(得分:0)

我发现了错误

该参数应该在函数中出现 在这种情况下,代码应该是

@app.route('/data_service/file/<string:db>/', methods=['GET','DELETE','POST','PUT'])
def file():