Skip to content

Instantly share code, notes, and snippets.

@mossey
Created September 20, 2018 12:27
Show Gist options
  • Save mossey/6e0f4c7f9d0de468bc89b5a764f683f7 to your computer and use it in GitHub Desktop.
Save mossey/6e0f4c7f9d0de468bc89b5a764f683f7 to your computer and use it in GitHub Desktop.
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