Skip to content

Instantly share code, notes, and snippets.

@matburt
Last active March 22, 2016 20:21
Show Gist options
  • Select an option

  • Save matburt/73bfbf85c2443f39d272 to your computer and use it in GitHub Desktop.

Select an option

Save matburt/73bfbf85c2443f39d272 to your computer and use it in GitHub Desktop.
A Generalized flask http request handler
#!/usr/bin/env python
from flask import Flask, request, abort, jsonify
app = Flask(__name__)
@app.route('/push', methods=['POST'])
def handle_push():
if not request.json:
abort(400)
if 'AAA' not in request.headers:
pass
if 'test' in request.json: # {"test": true }
pass
return jsonify({'status': 'ok'}), 200
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment