summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.py14
-rw-r--r--opendc/util/database.py3
-rw-r--r--opendc/util/rest.py2
3 files changed, 12 insertions, 7 deletions
diff --git a/main.py b/main.py
index 67ff72ac..56f8e7c1 100644
--- a/main.py
+++ b/main.py
@@ -12,11 +12,15 @@ from oauth2client import client, crypt
from opendc.models.user import User
from opendc.util import exceptions, rest
+if len(sys.argv) < 2:
+ print "config file path not given as argument"
+ sys.exit(1)
+
# Get keys from config file
-with open('/var/www/opendc.ewi.tudelft.nl/web-server/config/keys.json') as file:
+with open(sys.argv[1]) as file:
KEYS = json.load(file)
-STATIC_ROOT = os.path.join(KEYS['ROOT_DIR'], 'static', 'build')
+STATIC_ROOT = os.path.join(KEYS['ROOT_DIR'], 'opendc-frontend', 'build')
FLASK_CORE_APP = Flask(__name__, static_url_path='')
FLASK_CORE_APP.config['SECREY_KEY'] = KEYS['FLASK_SECRET']
@@ -55,7 +59,7 @@ def serve_projects():
def serve_web_server_test():
"""Serve the web server test."""
- return send_from_directory(os.path.join(KEYS['ROOT_DIR'], 'web-server', 'static'), 'index.html')
+ return send_from_directory(os.path.join(KEYS['ROOT_DIR'], 'opendc-web-server', 'static'), 'index.html')
@FLASK_CORE_APP.route('/<path:folder>/<path:filepath>')
def serve_static(folder, filepath):
@@ -64,7 +68,7 @@ def serve_static(folder, filepath):
if not folder in ['bower_components', 'img', 'scripts', 'styles']:
abort(404)
- return send_from_directory(os.path.join(KEYS['ROOT_DIR'], 'static', 'build', folder), filepath)
+ return send_from_directory(os.path.join(STATIC_ROOT, folder), filepath)
@FLASK_CORE_APP.route('/tokensignin', methods=['POST'])
def sign_in():
@@ -144,5 +148,5 @@ def receive_message(message):
)
-SOCKET_IO_CORE.run(FLASK_CORE_APP, port=8081)
+SOCKET_IO_CORE.run(FLASK_CORE_APP, host='0.0.0.0', port=8081)
diff --git a/opendc/util/database.py b/opendc/util/database.py
index 16fff5f0..2ef8b982 100644
--- a/opendc/util/database.py
+++ b/opendc/util/database.py
@@ -1,9 +1,10 @@
from datetime import datetime
import json
import sqlite3
+import sys
# Get keys from config file
-with open('/var/www/opendc.ewi.tudelft.nl/web-server/config/keys.json') as file:
+with open(sys.argv[1]) as file:
KEYS = json.load(file)
DATETIME_STRING_FORMAT = '%Y-%m-%dT%H:%M:%S'
diff --git a/opendc/util/rest.py b/opendc/util/rest.py
index a52b0082..65747762 100644
--- a/opendc/util/rest.py
+++ b/opendc/util/rest.py
@@ -7,7 +7,7 @@ from oauth2client import client, crypt
from opendc.util import exceptions, parameter_checker
-with open('/var/www/opendc.ewi.tudelft.nl/web-server/config/keys.json') as file:
+with open(sys.argv[1]) as file:
KEYS = json.load(file)
class Request(object):