forked from ExpDev07/coronavirus-tracker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
30 lines (24 loc) · 721 Bytes
/
__init__.py
File metadata and controls
30 lines (24 loc) · 721 Bytes
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
from flask import Flask
from flask import json
from flask_cors import CORS
from app.settings import *
# Create the flask application.
app = Flask(__name__)
CORS(app)
# 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)