Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5f1a422
add FastAPI uvicorn
Kilo59 Mar 21, 2020
8166a4d
define app
Kilo59 Mar 21, 2020
d79965e
create provisional models
Kilo59 Mar 22, 2020
cd64e47
define latest, location endpoints
Kilo59 Mar 22, 2020
21f4472
update models
Kilo59 Mar 22, 2020
b362750
change model name to match pre-existing model
Kilo59 Mar 22, 2020
033d924
defaults
Kilo59 Mar 22, 2020
b1a4742
update versions and response models
Kilo59 Mar 22, 2020
bdae7f0
divide sections
Kilo59 Mar 22, 2020
825de31
create middleware to attach the "data_source"
Kilo59 Mar 22, 2020
e31aad6
validation exception handler
Kilo59 Mar 22, 2020
20c49c2
get location by id
Kilo59 Mar 22, 2020
1cfdc2c
WIP get_all_locations
Kilo59 Mar 22, 2020
e8e50e8
add Totals
Kilo59 Mar 22, 2020
94a2f4e
Mount v2 of the application
Kilo59 Mar 22, 2020
091b461
add FIXME for timelines
Kilo59 Mar 22, 2020
ce9374c
end of file newlines
Kilo59 Mar 22, 2020
0d2f5f3
move models to models.py
Kilo59 Mar 22, 2020
04a35d8
exclude unset
Kilo59 Mar 22, 2020
6ecbc26
gunicorn with FastAPI
Kilo59 Mar 23, 2020
43bdeb0
change version name
Kilo59 Mar 23, 2020
86617e6
create Sources enum
Kilo59 Mar 23, 2020
21e952c
expose v1 and v2 apis via mounted WSGI app
Kilo59 Mar 23, 2020
0a2a262
lock dependencies for linux machines
Kilo59 Mar 23, 2020
8a19959
specify python 3.8 runtime for Heroku
Kilo59 Mar 23, 2020
85e493f
Merge pull request #3 from Kilo59/master
ExpDev07 Mar 23, 2020
ab817bd
add sources
Kilo59 Mar 24, 2020
ece30f3
update prefix
Kilo59 Mar 24, 2020
aec80ac
use separate v2 router
Kilo59 Mar 24, 2020
1949bea
add sources and make Timelines a boolean
Kilo59 Mar 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mount v2 of the application
  • Loading branch information
Kilo59 committed Mar 23, 2020
commit 94a2f4e8c0dee8ae7af34c2f8f52bfd923f5aefa
25 changes: 1 addition & 24 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
from flask import Flask
from flask_cors import CORS

# See PEP396.
__version__ = '2.0'

def create_app():
"""
Construct the core application.
"""
# Create flask app with CORS enabled.
app = Flask(__name__)
CORS(app)

# Set app config from settings.
app.config.from_pyfile('config/settings.py');

with app.app_context():
# Import routes.
from . import routes

# Register api endpoints.
app.register_blueprint(routes.api_v1)
app.register_blueprint(routes.api_v2)

# Return created app.
return app
from .core import create_app
24 changes: 24 additions & 0 deletions app/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from flask import Flask
from flask_cors import CORS

def create_app():
"""
Construct the core application.
"""
# Create flask app with CORS enabled.
app = Flask(__name__)
CORS(app)

# Set app config from settings.
app.config.from_pyfile('config/settings.py');

with app.app_context():
# Import routes.
from . import routes

# Register api endpoints.
app.register_blueprint(routes.api_v1)
app.register_blueprint(routes.api_v2)

# Return created app.
return app
4 changes: 4 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import fastapi
import pydantic
import uvicorn
from fastapi.middleware.wsgi import WSGIMiddleware

from .data import data_source
from .core import create_app

# #################################
# Models
Expand Down Expand Up @@ -153,6 +155,8 @@ def get_all_locations(
def get_location_by_id(request: fastapi.Request, id: int, timelines: int = 1):
return {"location": request.state.source.get(id).serialize(timelines)}

# mount the existing Flask app to /v2
APP.mount("/v2", WSGIMiddleware(create_app()))

if __name__ == "__main__":
uvicorn.run(
Expand Down