Created
September 20, 2018 12:27
-
-
Save mossey/6e0f4c7f9d0de468bc89b5a764f683f7 to your computer and use it in GitHub Desktop.
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 Flask, request, jsonify, json | |
app = Flask(__name__) | |
# the route is /getjson | |
# the method we use is POST | |
# the data is {"name":"Moses Nandwa","age":"10 years"} | |
@app.route('/getjson', methods=['POST']) | |
def add_message(): | |
# This is how you obtain data that you have POSTed | |
name = request.get_json()['name'] | |
age = request.get_json()['age'] | |
return "your name is "+name+" and your age is "+age+" years old" | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment