Skip to content

Commit 1bc26b7

Browse files
authored
Merge pull request #143 from Kilo59/FastAPI-conversion
FastAPI conversion
2 parents 799829d + d7d72d9 commit 1bc26b7

File tree

19 files changed

+506
-367
lines changed

19 files changed

+506
-367
lines changed

Pipfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ pytest = "*"
99
pylint = "*"
1010

1111
[packages]
12+
fastapi = "*"
1213
flask = "*"
1314
python-dotenv = "*"
1415
requests = "*"
1516
gunicorn = "*"
1617
flask-cors = "*"
1718
cachetools = "*"
1819
python-dateutil = "*"
20+
uvicorn = "*"
1921

2022
[requires]
2123
python_version = "3.8"
24+
25+
[scripts]
26+
dev = "uvicorn app.main:APP --reload"
27+
start = "uvicorn app.main:APP"

Pipfile.lock

Lines changed: 125 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: gunicorn app:create_app\(\)
1+
web: gunicorn app.main:APP -k uvicorn.workers.UvicornWorker

README.md

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ You can open the URL in your browser to further inspect the response. Or you can
4646
curl https://coronavirus-tracker-api.herokuapp.com/v2/locations | json_pp
4747
```
4848

49+
### Swagger/OpenAPI
50+
51+
Consume our API through [an interactive SwaggerUI](https://coronavirus-tracker-api.herokuapp.com/) (on mobile, use the [mobile friendly ReDocs](https://coronavirus-tracker-api.herokuapp.com/docs) instead for the best experience).
52+
53+
54+
The [OpenAPI](https://swagger.io/docs/specification/about/) json definition can be downloaded at https://coronavirus-tracker-api.herokuapp.com/openapi.json
55+
4956
## API Endpoints
5057

5158
### Sources Endpoint
@@ -122,6 +129,7 @@ __Sample response__
122129
"country": "Norway",
123130
"country_code": "NO",
124131
"province": "",
132+
"county": "",
125133
"last_updated": "2020-03-21T06:59:11.315422Z",
126134
"coordinates": { },
127135
"latest": { },
@@ -166,6 +174,7 @@ __Sample response__
166174
"country": "Thailand",
167175
"country_code": "TH",
168176
"province": "",
177+
"county": "",
169178
"last_updated": "2020-03-21T06:59:11.315422Z",
170179
"coordinates": {
171180
"latitude": "15",
@@ -182,6 +191,7 @@ __Sample response__
182191
"country": "Norway",
183192
"country_code": "NO",
184193
"province": "",
194+
"county": "",
185195
"last_updated": "2020-03-21T06:59:11.315422Z",
186196
"coordinates": {
187197
"latitude": "60.472",
@@ -231,29 +241,30 @@ GET /v2/locations?country_code=IT
231241
__Sample Response__
232242
```json
233243
{
234-
"latest": {
235-
"confirmed": 59138,
236-
"deaths": 5476,
237-
"recovered": 7024
238-
},
239-
"locations": [
240-
{
241-
"coordinates": {
242-
"latitude": "43",
243-
"longitude": "12"
244-
},
245-
"country": "Italy",
246-
"country_code": "IT",
247-
"id": 16,
248-
"last_updated": "2020-03-23T13:32:23.913872Z",
249-
"latest": {
250-
"confirmed": 59138,
251-
"deaths": 5476,
252-
"recovered": 7024
253-
},
254-
"province": ""
255-
}
256-
]
244+
"latest": {
245+
"confirmed": 59138,
246+
"deaths": 5476,
247+
"recovered": 7024
248+
},
249+
"locations": [
250+
{
251+
"id": 16,
252+
"country": "Italy",
253+
"country_code": "IT",
254+
"province": "",
255+
"county": "",
256+
"last_updated": "2020-03-23T13:32:23.913872Z",
257+
"coordinates": {
258+
"latitude": "43",
259+
"longitude": "12"
260+
},
261+
"latest": {
262+
"confirmed": 59138,
263+
"deaths": 5476,
264+
"recovered": 7024
265+
}
266+
}
267+
]
257268
}
258269
```
259270

@@ -385,7 +396,7 @@ You will need the following things properly installed on your computer.
385396

386397
## Running / Development
387398

388-
* `flask run`
399+
* `pipenv run dev`
389400
* Visit your app at [http://localhost:5000](http://localhost:5000).
390401

391402
### Running Tests

0 commit comments

Comments
 (0)