-
-
Save tarvos21/6cf0dee3e54bee8b98369255b8969c74 to your computer and use it in GitHub Desktop.
Sample of Flask receiving JSON
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
# If /json route receives header "application/json" | |
@app.route("/json", methods=['GET','POST']) | |
def json(): | |
app.logger.debug("JSON received...") | |
app.logger.debug(request.json) | |
if request.json: | |
mydata = request.json # will be | |
return "Thanks. Your age is %s" % mydata.get("age") | |
else: | |
return "no json received" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment