From 1e7ac8694072fc922bd58320d30ca2df3c37ee65 Mon Sep 17 00:00:00 2001 From: Anton Franzluebbers Date: Wed, 15 Dec 2021 15:49:06 -0500 Subject: [PATCH] switched to planetscale db --- CreateDB.sql | 12 ++++++------ run_flask_server.sh | 6 ++++++ static_website/index.html | 2 +- static_website/pair.html | 1 + velconnect/db.py | 3 ++- velconnect/routes/api.py | 4 +++- velconnect/templates/api_url.html | 2 +- velconnect/templates/single.html | 3 ++- 8 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 run_flask_server.sh diff --git a/CreateDB.sql b/CreateDB.sql index 883dc84..60299cd 100644 --- a/CreateDB.sql +++ b/CreateDB.sql @@ -1,8 +1,8 @@ DROP TABLE IF EXISTS `Room`; CREATE TABLE `Room` ( `room_id` VARCHAR(64) NOT NULL PRIMARY KEY, - `date_created` TIMESTAMP DEFAULT CURRENT_TIME, - `last_modified` TIMESTAMP DEFAULT CURRENT_TIME, + `date_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + `last_modified` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- Can be null if no owner `owner` VARCHAR(64), -- array of hw_ids of users allowed. Always includes the owner. Null for public @@ -22,9 +22,9 @@ CREATE TABLE `Headset` ( `current_room` VARCHAR(64) DEFAULT "0", -- changes relatively often. Generated by the headset `pairing_code` INT, - `date_created` TIMESTAMP DEFAULT CURRENT_TIME, + `date_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- the last time this headset was actually seen - `last_used` TIMESTAMP DEFAULT CURRENT_TIME, + `last_used` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `user_color` VARCHAR(9), `user_name` VARCHAR(64), `avatar_url` VARCHAR(128), @@ -38,7 +38,7 @@ CREATE TABLE `APIKey` ( -- 0 is all access, higher is less -- 10 is for headset clients `auth_level` INT, - `date_created` TIMESTAMP DEFAULT CURRENT_TIME, - `last_used` TIMESTAMP DEFAULT CURRENT_TIME, + `date_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + `last_used` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `uses` INT DEFAULT 0 ); \ No newline at end of file diff --git a/run_flask_server.sh b/run_flask_server.sh new file mode 100644 index 0000000..5be828c --- /dev/null +++ b/run_flask_server.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +export FLASK_APP="velconnect" +export FLASK_ENV=development +source env/bin/activate +flask run diff --git a/static_website/index.html b/static_website/index.html index 78e5485..6bae204 100644 --- a/static_website/index.html +++ b/static_website/index.html @@ -10,7 +10,7 @@ - + VEL Connect diff --git a/static_website/pair.html b/static_website/pair.html index 215ed6b..5b6fb91 100644 --- a/static_website/pair.html +++ b/static_website/pair.html @@ -10,6 +10,7 @@ + VEL Connect | Pair diff --git a/velconnect/db.py b/velconnect/db.py index 0b197c1..6ff5838 100644 --- a/velconnect/db.py +++ b/velconnect/db.py @@ -13,7 +13,8 @@ def connectToDB(): password=MYSQL_DATABASE_PASSWORD, db=MYSQL_DATABASE_DB, cursorclass=pymysql.cursors.DictCursor, - conv=conv + conv=conv, + ssl={"fake_flag_to_enable_tls":True}, ) curr = conn.cursor() diff --git a/velconnect/routes/api.py b/velconnect/routes/api.py index a1cd2c6..aa935a7 100644 --- a/velconnect/routes/api.py +++ b/velconnect/routes/api.py @@ -33,7 +33,9 @@ def get_all_headsets(): curr.execute(query, None) values = [dict(row) for row in curr.fetchall()] curr.close() - return jsonify(values) + response = jsonify(values) + response.headers.add('Access-Control-Allow-Origin', '*') + return response @bp.route('/pair_headset/', methods=['GET']) diff --git a/velconnect/templates/api_url.html b/velconnect/templates/api_url.html index 9491b78..259a10c 100644 --- a/velconnect/templates/api_url.html +++ b/velconnect/templates/api_url.html @@ -1 +1 @@ -http://velconnect.ugavel.com \ No newline at end of file +http://localhost:5000 \ No newline at end of file diff --git a/velconnect/templates/single.html b/velconnect/templates/single.html index e9fa139..c919dd6 100644 --- a/velconnect/templates/single.html +++ b/velconnect/templates/single.html @@ -13,7 +13,8 @@ - + + VEL Connect