Conversation
|
Looks good. I don't like that everything is in |
Yes absolutely, I planned on refactoring and moving those into a |
That's considerate of you, thank you. I really like dividing it up as much as possible, so you have the It's really just some simple refactoring that can be done at the end though. |
988a375 to
9ae7ff5
Compare
app/main.py
Outdated
|
|
||
|
|
||
| # mount the existing Flask app to /v2 | ||
| APP.mount("/v2", WSGIMiddleware(create_app())) |
There was a problem hiding this comment.
@ExpDev07
I'm not sure how this behaves with the /v1 endpoints. But (at least locally), the /v2 endpoints appear to be functional, including the redirect to the github page when hitting /v2.
There was a problem hiding this comment.
So FastAPI works with flask or? The v1 endpoints can be found at:
- https://coronavirus-tracker-api.herokuapp.com/all
- https://coronavirus-tracker-api.herokuapp.com/confirmed
- https://coronavirus-tracker-api.herokuapp.com/deaths
- https://coronavirus-tracker-api.herokuapp.com/recovered
I have checked the logs, and they are still in use by a lot of apps, so they need to work.
There was a problem hiding this comment.
@ExpDev07
It's mashing v1 and v2 together 😦
So because /v1 and /v2 are defined into the same app, this appears to put both /v2 and /v1 behind the /v2 prefix.
In order to separate them, I believe I need to create 2 separate flask apps and mount them separately.
This should be relatively simple.
For example /confirmed is part of /v1, but I can access it locally at /v2/confirmed when it should be /v1/confirmed.
There was a problem hiding this comment.
I probably need to do something like...
APP.mount("/v1", WSGIMiddleware(create_app("v1")))
APP.mount("/v2", WSGIMiddleware(create_app("v2")))There was a problem hiding this comment.
It should be /confirmed without any prefix :). Hmm, two different flask apps? Not really the biggest fan of that. FastAPI doesn't support blueprinting?
There was a problem hiding this comment.
I mean if the old v1 endpoints work then, then I guess it's fine.
There was a problem hiding this comment.
I'd be happy to get on a screen share, discord etc. to talk about this stuff (and deployment configuration, etc.).
There was a problem hiding this comment.
My Discord # is: Marius Big Ounce#2997.
There was a problem hiding this comment.
Just sent you an invite.
Kilo59#8819
There was a problem hiding this comment.
I think I accidentally declined it (lol), sent you one now.
|
@ExpDev07 Working on fixing that now. GET v2{
"latest": {
"confirmed": 53578,
"deaths": 4825,
"recovered": 6072
},
"locations": Array[1][
{
"coordinates": {
"latitude": "43",
"longitude": "12"
},
"country": "Italy",
"country_code": "IT",
"id": 16,
"last_updated": "2020-03-22T22:02:46.078243Z",
"latest": {
"confirmed": 53578,
"deaths": 4825,
"recovered": 6072
},
"province": ""
}
]
}v2-1{
"latest": {
"confirmed": 53578,
"deaths": 4825,
"recovered": 6072
},
"locations": Array[1][
{
"coordinates": {
"latitude": "43",
"longitude": "12"
},
"country": "Italy",
"country_code": "IT",
"id": 16,
"last_updated": "2020-03-22T22:12:42.421409+00:00",
"latest": {
"confirmed": 53578,
"deaths": 4825,
"recovered": 6072
},
"province": ""
}
]
} |
|
Awesome, how about the v1 endpoints? |
4561003 to
dc943b1
Compare
dc943b1 to
129a153
Compare
| flask = "*" | ||
| python-dotenv = "*" | ||
| requests = "*" | ||
| gunicorn = "*" |
There was a problem hiding this comment.
Can be removed now that we're using uvicorn.
There was a problem hiding this comment.
Actually we are running uvicorn workers via gunicorn.
https://www.uvicorn.org/deployment/
There was a problem hiding this comment.
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
…ided + doc changes + some cleanup
ExpDev07
left a comment
There was a problem hiding this comment.
There's an issue where when using alternative data-sources for locations, their fields won't show up. For example, /v2/locations?source=csbs won't display the county field as defined in app/location/csbs.py - CSBSLocation.
Fixed it by adding the |
… renamed models + some cleanup
|
To start the app, now use
|
ExpDev07
left a comment
There was a problem hiding this comment.
Awesome work dude! Looks like it's time for merge.
|
@all-contributors please add @Kilo59 for code, infrastructure, testing, and documentation. |
|
I've put up a pull request to add @Kilo59! 🎉 |


I thought I should open up my in-progress PR so that the maintainers can see what a transition to
#130 FastAPI would look like.
I didn't want to heavily redesign the application without input or discussion from the original creators.
But for example, some of the existing code could be refactored to take advantage of FastAPI's dependency injection system.
I've added 2
pipenvscripts, that can be used to run a local development server.To run it just type.
pipenv run dev_apporpipenv run appTODO:
GET /locationscsbssource/v1endpointssourceparam to all endpoints?timelinesquery param a boolean (in swagger doc)