HTTP 404 - 无法将 url 参数传递给 Flask 路由

Bla*_*e G 2 python http flask

对此的任何帮助表示赞赏。

我试图在 URL 查询字符串中将几个参数传递给我的 Flask 应用程序。

这是我的烧瓶代码

@application.route('/registeruser/', methods=['GET'])
def store_on_cloudant():
    qr = request.args.get('qr_code')
    fb_access_tok = request.args.get('fb_token')
    db.save({
        'qr': qr,
        'fb_access_tok': fb_access_tok

    })
    return
Run Code Online (Sandbox Code Playgroud)

这是 URL,我使用的是 GET,因为我正在浏览器中访问该页面

localhost:5000/registeruser/qr_code=qr12345&fb_token=token12345
Run Code Online (Sandbox Code Playgroud)

我收到 HTTP 404 错误。我是否正确传递参数?

Mar*_*ers 5

您缺少一个问号:

localhost:5000/registeruser/?qr_code=qr12345&fb_token=token12345
Run Code Online (Sandbox Code Playgroud)

没有问号的参数是URL 路径的一部分,而不是查询参数。