Skip to content

Instantly share code, notes, and snippets.

@joe-oli
Created December 4, 2019 01:03
Show Gist options
  • Save joe-oli/f5b981c808b88d69fbbef1f3b91cb876 to your computer and use it in GitHub Desktop.
Save joe-oli/f5b981c808b88d69fbbef1f3b91cb876 to your computer and use it in GitHub Desktop.
gist
//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