forked from vFlightDataSystems/VATSIM_EDST_API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
41 lines (31 loc) · 1.21 KB
/
app.py
File metadata and controls
41 lines (31 loc) · 1.21 KB
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
from flask import Flask
# from flask_cors import CORS
import threading
from blueprints.edst_bp import edst_blueprint
from blueprints.navdata_bp import navdata_blueprint
from blueprints.prefroute_bp import prefroute_blueprint
from blueprints.weather_bp import weather_blueprint
from blueprints.route_analysis_bp import route_analysis_blueprint
import mongo_client
PREFIX = '/api'
def create_app():
app = Flask(__name__)
# CORS(app)
register_extensions(app)
return app
def register_extensions(app):
app.register_blueprint(prefroute_blueprint, url_prefix=f'{PREFIX}/prefroute')
app.register_blueprint(navdata_blueprint, url_prefix=f'{PREFIX}/navdata')
app.register_blueprint(weather_blueprint, url_prefix=f'{PREFIX}/weather')
app.register_blueprint(edst_blueprint, url_prefix=f'{PREFIX}/edst')
app.register_blueprint(route_analysis_blueprint, url_prefix=f'{PREFIX}/route')
@app.before_request
def _get_mongo_clients():
mongo_client.get_reader_mongo_client()
@app.after_request
def _close_mongo_clients(response):
mongo_client.close_reader_mongo_client()
return response
if __name__ == '__main__':
app = create_app()
app.run(use_reloader=True)