Last active
March 22, 2016 20:21
-
-
Save matburt/73bfbf85c2443f39d272 to your computer and use it in GitHub Desktop.
A Generalized flask http request handler
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
| #!/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