summaryrefslogtreecommitdiff
path: root/web-server
diff options
context:
space:
mode:
Diffstat (limited to 'web-server')
-rw-r--r--web-server/LICENSE.md21
-rw-r--r--web-server/OpenDC.postman_collection.json61
-rw-r--r--web-server/main.py9
-rw-r--r--web-server/opendc/util/database.py2
4 files changed, 9 insertions, 84 deletions
diff --git a/web-server/LICENSE.md b/web-server/LICENSE.md
deleted file mode 100644
index 57288ae2..00000000
--- a/web-server/LICENSE.md
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2017 atlarge-research
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/web-server/OpenDC.postman_collection.json b/web-server/OpenDC.postman_collection.json
deleted file mode 100644
index c34dc310..00000000
--- a/web-server/OpenDC.postman_collection.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "variables": [],
- "info": {
- "name": "OpenDC",
- "_postman_id": "e8b68f59-29cb-71d0-6237-b22932c40f9c",
- "description": "Sample requests for developing the OpenDC API",
- "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
- },
- "item": [
- {
- "name": "Create New Simulation",
- "request": {
- "url": "localhost:8081/api/v1/simulations",
- "method": "POST",
- "header": [
- {
- "key": "Content-Type",
- "value": "application/json",
- "description": ""
- },
- {
- "key": "auth-token",
- "value": "PUT YOUR AUTH TOKEN HERE",
- "description": ""
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\r\n \"simulation\": {\r\n \"name\": \"Simulation Name\"\r\n }\r\n}"
- },
- "description": ""
- },
- "response": []
- },
- {
- "name": "Create New User",
- "request": {
- "url": "localhost:8081/api/v1/users",
- "method": "POST",
- "header": [
- {
- "key": "Content-Type",
- "value": "application/json",
- "description": ""
- },
- {
- "key": "auth-token",
- "value": "PUT YOUR AUTH TOKEN HERE",
- "description": ""
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\r\n \"user\": {\r\n \"email\": \"email@example.com\"\r\n }\r\n}"
- },
- "description": ""
- },
- "response": []
- }
- ]
-} \ No newline at end of file
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)
diff --git a/web-server/opendc/util/database.py b/web-server/opendc/util/database.py
index 12d6afc9..0402c2e1 100644
--- a/web-server/opendc/util/database.py
+++ b/web-server/opendc/util/database.py
@@ -14,7 +14,7 @@ class Database:
def __init__(self):
self.opendc_db = None
- def init_database(self, user, password, database, host):
+ def initialize_database(self, user, password, database, host):
"""Initializes the database connection."""
user = urllib.parse.quote_plus(user)