diff --git a/misc/create_schema.sql b/misc/create_schema.sql index 9978bb2..1bb323f 100644 --- a/misc/create_schema.sql +++ b/misc/create_schema.sql @@ -1,5 +1,7 @@ CREATE DATABASE `bremen_calling` /*!40100 DEFAULT CHARACTER SET utf8mb4 */; +USE `bremen_calling` + CREATE TABLE `participant` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(128) DEFAULT NULL, diff --git a/misc/sample_data.sql b/misc/sample_data.sql index 74a81d9..cf511af 100644 --- a/misc/sample_data.sql +++ b/misc/sample_data.sql @@ -18,9 +18,11 @@ -- Dumping data for table `berth` -- +USE `bremen_calling`; + LOCK TABLES `berth` WRITE; /*!40000 ALTER TABLE `berth` DISABLE KEYS */; -INSERT INTO `berth` (`id`, `name`) VALUES (1,'Roland Mühle'),(1,'Stahlwerk'),(2,'Kellogs'); +INSERT INTO `berth` (`id`, `name`) VALUES (1,'Roland Mühle'),(2,'Stahlwerk'),(3,'Kellogs'); /*!40000 ALTER TABLE `berth` ENABLE KEYS */; UNLOCK TABLES; diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index d465b00..76b5496 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -5,11 +5,13 @@ import json bp = Blueprint('ships', __name__) + @bp.route('/ships', methods=['get']) @auth_guard() # no restriction by role def GetShips(): - if 'Authentication' in request.headers: - token = request.headers.get('Authentication') + + if 'Authorization' in request.headers: + token = request.headers.get('Authorization') return impl.ships.GetShips(token) else: return json.dumps("not authenticated"), 403 diff --git a/src/server/BreCal/connection_data.json b/src/server/BreCal/connection_data.json index f07690d..8feca32 100644 --- a/src/server/BreCal/connection_data.json +++ b/src/server/BreCal/connection_data.json @@ -5,5 +5,6 @@ "password" : "HalloWach23", "pool_name" : "brecal_pool", "pool_size" : 20, -"database" : "bremen_calling" +"database" : "bremen_calling", +"autocommit" : true } \ No newline at end of file diff --git a/src/server/BreCal/local_db.py b/src/server/BreCal/local_db.py index fd2b83f..189f94c 100644 --- a/src/server/BreCal/local_db.py +++ b/src/server/BreCal/local_db.py @@ -28,5 +28,5 @@ def initPool(): except mysql.connector.PoolError as e: logging.error(f"Failed to create connection pool: {e}") print(e) - except e: + except Exception as e: print(e) \ No newline at end of file diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index 3899bdc..3420840 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -144,7 +144,7 @@ class Times: @dataclass class User: - + id: int participant_id: int first_name: str @@ -161,6 +161,7 @@ class Ship(Schema): name: str imo: int callsign: str + participant_id: int length: float width: float created: datetime diff --git a/src/server/flaskapp.wsgi b/src/server/flaskapp.wsgi new file mode 100644 index 0000000..1dc7818 --- /dev/null +++ b/src/server/flaskapp.wsgi @@ -0,0 +1,12 @@ +import sys +import logging + +sys.path.insert(0, '/var/www/brecal/server') +sys.path.insert(0, '/var/www/brecal/venv/lib/python3.10/site-packages/') + +# Set up logging +logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) + +# Import and run the Flask app +from BreCal import create_app +application = create_app() \ No newline at end of file