-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (26 loc) · 981 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask, Blueprint, request, Response
from flask_cors import CORS
from emails import emails
from metrics import metrics
from pref import pref
app = Flask(__name__)
CORS(app, supports_credentials=True)
app.config['CORS_HEADERS'] = 'Content-Type'
app.register_blueprint(emails, url_prefix='/emails')
app.register_blueprint(metrics, url_prefix='/metrics')
app.register_blueprint(pref, url_prefix='/pref')
# Source: https://fetch.spec.whatwg.org/
@app.before_request
def handle_preflight():
if request.method == "OPTIONS":
res = Response()
res.headers['X-Content-Type-Options'] = '*'
res.headers['Access-Control-Allow-Origin'] = '*'
res.headers['Access-Control-Allow-Methods'] = '*'
res.headers['Access-Control-Allow-Headers'] = '*'
return res
@app.route('/health', methods=['GET', 'POST'])
def healthGet():
return {'status': 'OK'}
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)