-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
47 lines (33 loc) · 1.22 KB
/
app.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Start the flask server by running:
$ python app.py
And then head to http://127.0.0.1:5000/ in your browser to see the map displayed
"""
import json
import os
from typing import Dict
from dotenv import load_dotenv
from flask import Flask
from flask_compress import Compress
import fover.api.main as api_main
def setup_app_conf(app: Flask, prefix: str) -> None:
envs = {k: v for k, v in os.environ.items() if k.startswith(prefix) and v}
for k, v in envs.items():
key = k[len(prefix) :] # Strip the prefix
try:
app.config[key] = json.loads(v)
except ValueError as e:
# Value is a raw string
app.config[key] = v
load_dotenv()
# static_url_path – can be used to specify a different path for the static files on the web.
# Defaults to the name of the static_folder folder.
# static_folder – the folder with static files that should be served at static_url_path.
# Defaults to the 'static' folder in the root path of the application.
FLASK_APP_ENV_PREFIX = "FLASK_APP_"
app = Flask(__name__)
setup_app_conf(app, FLASK_APP_ENV_PREFIX)
Compress(app)
app.register_blueprint(api_main.bp)
if __name__ == "__main__":
app.run(debug=True)