Skip to content

Commit 915702e

Browse files
author
ExpDev07
committed
added source
1 parent c0bd697 commit 915702e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from flask import Flask
2+
from flask import json
23
from flask_cors import CORS
34
from app.settings import *
45

@@ -9,6 +10,21 @@
910
# Import assets, models, routes, etc.
1011
from . import routes
1112

13+
@app.after_request
14+
def set_source(response):
15+
"""
16+
Attaches the source to the response.
17+
"""
18+
body = response.get_json()
19+
20+
# Attach only if we're dealing with a dict.
21+
if type(body) is dict:
22+
body['source'] = 'https://github.com/ExpDev07/coronavirus-tracker-api'
23+
response.data = json.dumps(body)
24+
25+
# Finally, return the modified response.
26+
return response
27+
1228
# Run the application (server).
1329
if __name__ == 'main':
1430
app.run(port=PORT, threaded=True)

app/data/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def get_data(category):
2828
locations = []
2929

3030
for item in data:
31-
3231
# Filter out all the dates.
3332
history = dict(filter(lambda element: date_util.is_date(element[0]), item.items()))
3433

0 commit comments

Comments
 (0)