Skip to content

Commit 1117c22

Browse files
committed
Replaced flask based v1. Not currently passing integration tests, need to change them to work with new implementation
1 parent b6ec0c7 commit 1117c22

File tree

13 files changed

+67
-69
lines changed

13 files changed

+67
-69
lines changed

app/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
import uvicorn
1111
from fastapi import FastAPI, Request, Response
1212
from fastapi.middleware.cors import CORSMiddleware
13-
from fastapi.middleware.wsgi import WSGIMiddleware
13+
# from fastapi.middleware.wsgi import WSGIMiddleware
1414
from fastapi.responses import JSONResponse
1515

1616
from .core import create_app
1717
from .data import data_source
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.v1 import router as v1router
2122
from .router.v2 import router as v2router
2223

2324
# ############
@@ -83,12 +84,14 @@ async def handle_validation_error(request: Request, exc: pydantic.error_wrappers
8384

8485

8586
# Include routers.
86-
# APP.include_router(router, prefix="/", tags=["v1"])
87+
APP.include_router(v1router, prefix="", tags=["v1"])
8788
APP.include_router(v2router, prefix="/v2", tags=["v2"])
8889

90+
'''
8991
# mount the existing Flask app
9092
# v1 @ /
9193
APP.mount("/", WSGIMiddleware(create_app()))
94+
'''
9295

9396

9497
# Running of app.

app/router/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from fastapi import APIRouter
22

3-
# Create the router.
4-
# router = APIRouter()
5-
63
# The routes.
74
from .v2 import latest, sources, locations # isort:skip
8-
# from .v1 import confirmed, deaths, recovered, all
5+
from .v1 import confirmed, deaths, recovered, all

app/router/v1/__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/v1/all.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#from flask import jsonify
2+
3+
from ...services.location.jhu import get_category
4+
from . import router
5+
6+
7+
@router.get("/all")
8+
def all():
9+
# Get all the categories.
10+
confirmed = get_category("confirmed")
11+
deaths = get_category("deaths")
12+
recovered = get_category("recovered")
13+
14+
return {
15+
# Data.
16+
"confirmed": confirmed,
17+
"deaths": deaths,
18+
"recovered": recovered,
19+
# Latest.
20+
"latest": {"confirmed":confirmed["latest"], "deaths": deaths["latest"], "recovered": recovered["latest"],},
21+
}

app/router/v1/confirmed.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# from flask import jsonify
2+
3+
# from ...routes import api_v1 as api
4+
from ...services.location.jhu import get_category
5+
from . import router
6+
7+
8+
@router.get("/confirmed")
9+
def confirmed():
10+
11+
return {
12+
get_category("confirmed")
13+
}

app/router/v1/deaths.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# from flask import jsonify
2+
3+
# from ...routes import api_v1 as api
4+
from ...services.location.jhu import get_category
5+
from . import router
6+
7+
8+
@router.get("/deaths")
9+
def deaths():
10+
return {
11+
get_category("deaths")
12+
}

app/router/v1/recovered.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# from flask import jsonify
2+
3+
# from ...routes import api_v1 as api
4+
from ...services.location.jhu import get_category
5+
from . import router
6+
7+
8+
@router.get("/recovered")
9+
def recovered():
10+
return {
11+
get_category("recovered")
12+
}

app/routes/__init__.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/routes/v1/__init__.py

Whitespace-only changes.

app/routes/v1/all.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)