diff --git a/app/__init__.py b/app/__init__.py index 5f35fea9..4d852fc2 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -10,21 +10,6 @@ # Import assets, models, routes, etc. from . import routes -@app.after_request -def set_source(response): - """ - Attaches the source to the response. - """ - body = response.get_json() - - # Attach only if we're dealing with a dict. - if type(body) is dict: - body['source'] = 'https://github.com/ExpDev07/coronavirus-tracker-api' - response.data = json.dumps(body) - - # Finally, return the modified response. - return response - # Run the application (server). if __name__ == 'main': app.run(port=PORT, threaded=True) \ No newline at end of file diff --git a/app/data/__init__.py b/app/data/__init__.py index a515f637..9b811f3c 100644 --- a/app/data/__init__.py +++ b/app/data/__init__.py @@ -2,8 +2,7 @@ import csv from cachetools import cached, TTLCache from app.utils import date as date_util - -from . import countrycodes as cc +from app.utils import countrycodes """ Base URL for fetching data. @@ -43,7 +42,7 @@ def get_data(category): locations.append({ # General info. 'country': country, - 'country_code': cc.country_code(country), + 'country_code': countrycodes.country_code(country), 'province': item['Province/State'], # Coordinates. @@ -65,5 +64,6 @@ def get_data(category): # Return the final data. return { 'locations': locations, - 'latest': latest + 'latest': latest, + 'source': 'https://github.com/ExpDev07/coronavirus-tracker-api', } diff --git a/app/utils/__init__.py b/app/utils/__init__.py index ca6360e9..9a38d4d3 100644 --- a/app/utils/__init__.py +++ b/app/utils/__init__.py @@ -1,4 +1,4 @@ from . import date - +from . import countrycodes diff --git a/app/data/countrycodes.py b/app/utils/countrycodes.py similarity index 100% rename from app/data/countrycodes.py rename to app/utils/countrycodes.py