forked from ExpDev07/coronavirus-tracker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv1.py
More file actions
51 lines (37 loc) · 1.08 KB
/
v1.py
File metadata and controls
51 lines (37 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""app.routers.v1.py"""
from fastapi import APIRouter
from ..services.location.jhu import get_category
V1 = APIRouter()
@V1.get("/all")
async def all_categories():
"""Get all the categories."""
confirmed = await get_category("confirmed")
deaths = await get_category("deaths")
recovered = await get_category("recovered")
return {
# Data.
"confirmed": confirmed,
"deaths": deaths,
"recovered": recovered,
# Latest.
"latest": {
"confirmed": confirmed["latest"],
"deaths": deaths["latest"],
"recovered": recovered["latest"],
},
}
@V1.get("/confirmed")
async def get_confirmed():
"""Confirmed cases."""
confirmed_data = await get_category("confirmed")
return confirmed_data
@V1.get("/deaths")
async def get_deaths():
"""Total deaths."""
deaths_data = await get_category("deaths")
return deaths_data
@V1.get("/recovered")
async def get_recovered():
"""Recovered cases."""
recovered_data = await get_category("recovered")
return recovered_data