-
-
Notifications
You must be signed in to change notification settings - Fork 314
FastAPI conversion #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
FastAPI conversion #143
Changes from 45 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
5f1a422
add FastAPI uvicorn
Kilo59 8166a4d
define app
Kilo59 d79965e
create provisional models
Kilo59 cd64e47
define latest, location endpoints
Kilo59 21f4472
update models
Kilo59 b362750
change model name to match pre-existing model
Kilo59 033d924
defaults
Kilo59 b1a4742
update versions and response models
Kilo59 bdae7f0
divide sections
Kilo59 825de31
create middleware to attach the "data_source"
Kilo59 e31aad6
validation exception handler
Kilo59 20c49c2
get location by id
Kilo59 1cfdc2c
WIP get_all_locations
Kilo59 e8e50e8
add Totals
Kilo59 94a2f4e
Mount v2 of the application
Kilo59 091b461
add FIXME for timelines
Kilo59 ce9374c
end of file newlines
Kilo59 0d2f5f3
move models to models.py
Kilo59 04a35d8
exclude unset
Kilo59 6ecbc26
gunicorn with FastAPI
Kilo59 43bdeb0
change version name
Kilo59 86617e6
create Sources enum
Kilo59 21e952c
expose v1 and v2 apis via mounted WSGI app
Kilo59 0a2a262
lock dependencies for linux machines
Kilo59 8a19959
specify python 3.8 runtime for Heroku
Kilo59 3009428
Merge pull request #2 from ExpDev07/master
ExpDev07 85e493f
Merge pull request #3 from Kilo59/master
ExpDev07 9d22cd5
Fast api conversion (#4)
Kilo59 49800c3
Merge branch 'master' into FastAPI-conversion
Kilo59 ab817bd
add sources
Kilo59 ece30f3
update prefix
Kilo59 aec80ac
use separate v2 router
Kilo59 1949bea
add sources and make Timelines a boolean
Kilo59 f7b7354
fixed wrong date format and timelines appearing null
0ba6749
Merge pull request #6 from ExpDev07/master
ExpDev07 fe60577
Merge pull request #7 from ExpDev07/master
ExpDev07 7a0d38c
Merge pull request #8 from ExpDev07/master
ExpDev07 f0e36a2
replace Flask based v2
Kilo59 5202876
Fix existing tests
Kilo59 129a153
add api_client testing client fixture and basic swagger doc tests
Kilo59 d343a35
add Swagger information to the Readme
Kilo59 8b7d299
Improve middleware.
ExpDev07 2a6892b
fix tests
6b4447b
cleanup and use single quotes to follow same conventions
1dd1cf0
fixes source middleware not returning 404 when invalid source is prov…
a0542f2
add county to Country model
Kilo59 8978af1
test /locations codes
Kilo59 c7cb10c
better swagger description
Kilo59 2854739
forgot to import pytest
Kilo59 45dc4d4
add /latest test
Kilo59 304de58
changed start dev script to "pipenv run dev" and "pipenv run start" +…
88a6faf
fixed querying of all properties
a55e03e
update README with doc
0e3d352
small edit in models file
ExpDev07 d7d72d9
add github link
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| web: gunicorn app:create_app\(\) | ||
| web: gunicorn app.main:APP -k uvicorn.workers.UvicornWorker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 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) | ||
|
|
||
| # Return created app. | ||
| return app |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed now that we're using uvicorn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we are running
uvicornworkers viagunicorn.https://www.uvicorn.org/deployment/
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also seems to imply that it's okay to run directly it with
uvicorn.It might be worth doing a performance test on both deployment methods.
https://fastapi.tiangolo.com/deployment/#alternatively-deploy-fastapi-without-docker