Created
December 4, 2019 01:03
-
-
Save joe-oli/f5b981c808b88d69fbbef1f3b91cb876 to your computer and use it in GitHub Desktop.
gist
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
//Server-side | |
@app.route('/message', methods=['POST']) | |
def print_post(): | |
if request.headers['Content-Type'] == 'text/plain': | |
logging.warning(request.data) | |
return "Text Message: " + request.data | |
else: | |
logging.warning('didnt work') | |
return 'Unsupported Media Type' | |
//Client-side | |
$.ajax({ | |
type: "POST", | |
url: "https://localhost:8090/message", | |
data: 'this is a message', // <-- Put comma here | |
contentType: 'text/plain' | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment