Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
v2 passing tests with close to new proposed structure. Edited __init_…
…_ files so v1 and v2 have their own versions of 'router'.
  • Loading branch information
ibhuiyan17 committed Mar 28, 2020
commit 4e6e8232380f87a6b0edfdbcd87fb5f6e387fa29
4 changes: 3 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .models.latest import LatestResponse as Latest
from .models.location import LocationResponse as Location
from .models.location import LocationsResponse as Locations
from .router import router
from .router.v2 import router

# ############
# FastAPI App
Expand Down Expand Up @@ -83,12 +83,14 @@ async def handle_validation_error(request: Request, exc: pydantic.error_wrappers


# Include routers.
# APP.include_router(router, prefix="/", tags=["v1"])
APP.include_router(router, prefix="/v2", tags=["v2"])

# mount the existing Flask app
# v1 @ /
APP.mount("/", WSGIMiddleware(create_app()))


# Running of app.
if __name__ == "__main__":
uvicorn.run(
Expand Down
3 changes: 2 additions & 1 deletion app/router/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from fastapi import APIRouter

# Create the router.
router = APIRouter()
# router = APIRouter()

# The routes.
from .v2 import latest, sources, locations # isort:skip
# from .v1 import confirmed, deaths, recovered, all
3 changes: 3 additions & 0 deletions app/router/v2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
2 changes: 1 addition & 1 deletion app/router/v2/latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ...enums.sources import Sources
from ...models.latest import LatestResponse as Latest
from .. import router
from . import router


@router.get("/latest", response_model=Latest)
Expand Down
2 changes: 1 addition & 1 deletion app/router/v2/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ...enums.sources import Sources
from ...models.location import LocationResponse as Location
from ...models.location import LocationsResponse as Locations
from .. import router
from . import router


@router.get("/locations", response_model=Locations, response_model_exclude_unset=True)
Expand Down
2 changes: 1 addition & 1 deletion app/router/v2/sources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ...data import data_sources
from .. import router
from . import router


@router.get("/sources")
Expand Down