Skip to content

Instantly share code, notes, and snippets.

@hughpearse
Last active November 22, 2019 14:24
Show Gist options
  • Save hughpearse/38cd8a86c3db5018abd7e2891ff1f6b2 to your computer and use it in GitHub Desktop.
Save hughpearse/38cd8a86c3db5018abd7e2891ff1f6b2 to your computer and use it in GitHub Desktop.
#!/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