Created
October 1, 2018 22:20
-
-
Save hughdbrown/1d7aba9784fe7ae74e652a8aa6f710a1 to your computer and use it in GitHub Desktop.
Notes on how flask request paramets map to an HTTP request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import request | |
request.view_args | |
@app.route("/data/<section>") | |
def data(section): | |
assert section == request.view_args['section'] | |
For URL Query parameter, use request.args | |
search = request.args.get("search") | |
page = request.args.get("page") | |
For Form input, use request.form | |
email = request.form.get('email') | |
password = request.form.get('password') | |
For data type application/json, use request.data | |
# data in string format and you have to parse into dictionary | |
data = request.data | |
dataDict = json.loads(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment