Complex Routing For Get Request From Html Form In Flask
I'm trying to create complex routing for a get request that looks like this: @app.route('/get-details?id=&code=', methods=['GET']) @login_required
Solution 1:
Don't put query args in the route definition. Instead, get them from request.args
. args.get
takes an optional type
argument, so you can still validate the type of the value.
@app.route('/get_details')defget_details():
id = request.args.get('id', type=int)
code = request.args.get('code', type=int)
...
For the solution to your specific error, read the error message. You have a route with two url groups, but you don't supply values for them to url_for
. Since you only know the args after the form is filled out on the client, this becomes a good argument for why you don't put query args in the route.
url_for('get_details', id=2, code=108)
Post a Comment for "Complex Routing For Get Request From Html Form In Flask"