File tree Expand file tree Collapse file tree 3 files changed +29
-24
lines changed
Expand file tree Collapse file tree 3 files changed +29
-24
lines changed Original file line number Diff line number Diff line change 1- from flask import Flask
2- from flask_cors import CORS
3-
41# See PEP396.
52__version__ = '2.0'
63
7- def create_app ():
8- """
9- Construct the core application.
10- """
11- # Create flask app with CORS enabled.
12- app = Flask (__name__ )
13- CORS (app )
14-
15- # Set app config from settings.
16- app .config .from_pyfile ('config/settings.py' );
17-
18- with app .app_context ():
19- # Import routes.
20- from . import routes
21-
22- # Register api endpoints.
23- app .register_blueprint (routes .api_v1 )
24- app .register_blueprint (routes .api_v2 )
25-
26- # Return created app.
27- return app
4+ from .core import create_app
Original file line number Diff line number Diff line change 1+ from flask import Flask
2+ from flask_cors import CORS
3+
4+ def create_app ():
5+ """
6+ Construct the core application.
7+ """
8+ # Create flask app with CORS enabled.
9+ app = Flask (__name__ )
10+ CORS (app )
11+
12+ # Set app config from settings.
13+ app .config .from_pyfile ('config/settings.py' );
14+
15+ with app .app_context ():
16+ # Import routes.
17+ from . import routes
18+
19+ # Register api endpoints.
20+ app .register_blueprint (routes .api_v1 )
21+ app .register_blueprint (routes .api_v2 )
22+
23+ # Return created app.
24+ return app
Original file line number Diff line number Diff line change 1010import fastapi
1111import pydantic
1212import uvicorn
13+ from fastapi .middleware .wsgi import WSGIMiddleware
1314
1415from .data import data_source
16+ from .core import create_app
1517
1618# #################################
1719# Models
@@ -153,6 +155,8 @@ def get_all_locations(
153155def get_location_by_id (request : fastapi .Request , id : int , timelines : int = 1 ):
154156 return {"location" : request .state .source .get (id ).serialize (timelines )}
155157
158+ # mount the existing Flask app to /v2
159+ APP .mount ("/v2" , WSGIMiddleware (create_app ()))
156160
157161if __name__ == "__main__" :
158162 uvicorn .run (
You can’t perform that action at this time.
0 commit comments