Skip to content

Instantly share code, notes, and snippets.

@viveksb007
Created February 1, 2018 11:59
Show Gist options
  • Save viveksb007/282ad9e7a2dcb4a4a78b88ecccdc1356 to your computer and use it in GitHub Desktop.
Save viveksb007/282ad9e7a2dcb4a4a78b88ecccdc1356 to your computer and use it in GitHub Desktop.
from flask import json
@app.route('/messages', methods = ['POST'])
def api_message():
if request.headers['Content-Type'] == 'text/plain':
return "Text Message: " + request.data
elif request.headers['Content-Type'] == 'application/json':
return "JSON Message: " + json.dumps(request.json)
else:
return "415 Unsupported Media Type ;)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment