summaryrefslogtreecommitdiff
path: root/web-server/main.py
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-30 17:26:19 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:44:35 +0200
commitcac980546e15882a232ce234cbde3e0cda693352 (patch)
tree50fed18858c6c5cbb11c3ecb690ebbff8bc98525 /web-server/main.py
parent80730074581b8a934fb5b064a54912f620fad978 (diff)
Get Docker setup working
Diffstat (limited to 'web-server/main.py')
-rw-r--r--web-server/main.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/web-server/main.py b/web-server/main.py
index 6d2f8747..94696e8d 100644
--- a/web-server/main.py
+++ b/web-server/main.py
@@ -15,17 +15,24 @@ from opendc.util.exceptions import AuthorizationTokenError, RequestInitializatio
TEST_MODE = "OPENDC_FLASK_TESTING" in os.environ
+# Specify the directory of static assets
if TEST_MODE:
STATIC_ROOT = os.curdir
else:
+ STATIC_ROOT = os.path.join(os.environ['OPENDC_ROOT_DIR'], 'frontend', 'build')
+
+# Set up database if not testing
+if not TEST_MODE:
database.DB.initialize_database(user=os.environ['OPENDC_DB_USERNAME'],
password=os.environ['OPENDC_DB_PASSWORD'],
database=os.environ['OPENDC_DB'],
host='localhost')
- STATIC_ROOT = os.path.join(os.environ['OPENDC_ROOT_DIR'], 'opendc-frontend', 'build')
+# Set up the core app
FLASK_CORE_APP = Flask(__name__, static_url_path='', static_folder=STATIC_ROOT)
FLASK_CORE_APP.config['SECRET_KEY'] = os.environ['OPENDC_FLASK_SECRET']
+
+# Set up CORS support for local setups
if 'localhost' in os.environ['OPENDC_SERVER_BASE_URL']:
CORS(FLASK_CORE_APP)