-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
42 lines (36 loc) · 1.03 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
from blueprints import blueprints
from flask import Flask, jsonify
from flask_cors import CORS
def list_routes(app):
output = {}
rules = list(app.url_map.iter_rules())
funcs = list(app.view_functions.items())
for x,y in zip(rules, funcs):
out = {
y[0]:{
'route':str(x),
'doc':y[1].__doc__
}
}
output.update(out)
return output
def create_app():
"""Flask Create App method"""
app = Flask(__name__)
CORS(app)
for x in blueprints:
app.register_blueprint(x)
@app.after_request
def after_request(response):
header = response.headers
header['Access-Control-Allow-Origin'] = '*'
header['Accept-Ranges'] = 'bytes'
# Other headers can be added here if needed
return response
@app.route('/')
def index():
"""Index Route to List all available routes with their documentation"""
return jsonify(
list_routes(app)
)
return app