Last active
November 22, 2019 14:24
-
-
Save hughpearse/38cd8a86c3db5018abd7e2891ff1f6b2 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
#!/usr/bin/env python3.7 | |
from flask import Flask, Response, request | |
app = Flask(__name__) | |
def printReq(request): | |
print(">>>>") | |
print(request.method, request.path, request.environ.get('SERVER_PROTOCOL', 'HTTP/1.1')) | |
print(request.headers) | |
print(request.data.decode("utf-8")) | |
print("<<<<") | |
@app.route('/', methods=['GET', 'POST']) | |
def hello(): | |
printReq(request) | |
responseBody = '{"hungry":false}' | |
return Response(responseBody, mimetype='application/json') | |
if __name__ == '__main__': | |
app.run(host='', port=8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment