File tree Expand file tree Collapse file tree 2 files changed +29
-21
lines changed
Expand file tree Collapse file tree 2 files changed +29
-21
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ GET /v2/locations?country_code=US
7676
7777Include timelines.
7878``` http
79- GET /v2/locations?country_code=US& timelines=true
79+ GET /v2/locations?timelines=1
8080```
8181
8282### Getting a specific location (includes timelines by default).
@@ -86,28 +86,32 @@ GET /v2/locations/:id
8686``` json
8787{
8888 "location" : {
89- "id" : 39 ,
90- "country" : " Norway" ,
91- "country_code" : " NO" ,
92- "province" : " " ,
93- "coordinates" : { },
94- "latest" : { },
95- "timelines" : {
96- "confirmed" : {
97- "latest" : 1463 ,
98- "timeline" : {
99- "2020-03-16T00:00:00Z" : 1333 ,
100- "2020-03-17T00:00:00Z" : 1463
101- }
102- },
103- "deaths" : { },
104- "recovered" : { }
105- }
89+ "id" : 39 ,
90+ "country" : " Norway" ,
91+ "country_code" : " NO" ,
92+ "province" : " " ,
93+ "coordinates" : { },
94+ "latest" : { },
95+ "timelines" : {
96+ "confirmed" : {
97+ "latest" : 1463 ,
98+ "timeline" : {
99+ "2020-03-16T00:00:00Z" : 1333 ,
100+ "2020-03-17T00:00:00Z" : 1463
101+ }
102+ },
103+ "deaths" : { },
104+ "recovered" : { }
106105 }
107106 }
108107}
109108```
110109
110+ Exclude timelines.
111+ ``` http
112+ GET /v2/locations?timelines=0
113+ ```
114+
111115## Data
112116
113117The data comes from the [ 2019 Novel Coronavirus (nCoV) Data Repository, provided
Original file line number Diff line number Diff line change 1+ from distutils .util import strtobool
12from flask import jsonify , request , current_app as app
23from ...services import jhu
34
45@app .route ('/v2/locations' )
56def locations ():
67 # Query parameters.
7- timelines = request .args .get ('timelines' , type = bool , default = False )
8+ timelines = strtobool ( request .args .get ('timelines' , default = '0' ) )
89 country_code = request .args .get ('country_code' , type = str )
910
1011 # Retrieve all the locations.
@@ -23,7 +24,10 @@ def locations():
2324
2425@app .route ('/v2/locations/<int:id>' )
2526def location (id ):
26- # Serialize the location with timelines.
27+ # Query parameters.
28+ timelines = strtobool (request .args .get ('timelines' , default = '1' ))
29+
30+ # Return serialized location.
2731 return jsonify ({
28- 'location' : jhu .get (id ).serialize (True )
32+ 'location' : jhu .get (id ).serialize (timelines )
2933 })
You can’t perform that action at this time.
0 commit comments