Created
February 1, 2018 11:59
-
-
Save viveksb007/282ad9e7a2dcb4a4a78b88ecccdc1356 to your computer and use it in GitHub Desktop.
This file contains 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 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