Skip to content

Commit 4e6e823

Browse files
committed
v2 passing tests with close to new proposed structure. Edited __init__ files so v1 and v2 have their own versions of 'router'.
1 parent dfd1dc9 commit 4e6e823

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

app/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from .models.latest import LatestResponse as Latest
1919
from .models.location import LocationResponse as Location
2020
from .models.location import LocationsResponse as Locations
21-
from .router import router
21+
from .router.v2 import router
2222

2323
# ############
2424
# FastAPI App
@@ -83,12 +83,14 @@ async def handle_validation_error(request: Request, exc: pydantic.error_wrappers
8383

8484

8585
# Include routers.
86+
# APP.include_router(router, prefix="/", tags=["v1"])
8687
APP.include_router(router, prefix="/v2", tags=["v2"])
8788

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

93+
9294
# Running of app.
9395
if __name__ == "__main__":
9496
uvicorn.run(

app/router/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from fastapi import APIRouter
22

33
# Create the router.
4-
router = APIRouter()
4+
# router = APIRouter()
55

66
# The routes.
77
from .v2 import latest, sources, locations # isort:skip
8+
# from .v1 import confirmed, deaths, recovered, all

app/router/v2/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from fastapi import APIRouter
2+
3+
router = APIRouter()

app/router/v2/latest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from ...enums.sources import Sources
44
from ...models.latest import LatestResponse as Latest
5-
from .. import router
5+
from . import router
66

77

88
@router.get("/latest", response_model=Latest)

app/router/v2/locations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ...enums.sources import Sources
44
from ...models.location import LocationResponse as Location
55
from ...models.location import LocationsResponse as Locations
6-
from .. import router
6+
from . import router
77

88

99
@router.get("/locations", response_model=Locations, response_model_exclude_unset=True)

app/router/v2/sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ...data import data_sources
2-
from .. import router
2+
from . import router
33

44

55
@router.get("/sources")

0 commit comments

Comments
 (0)