From 69241d1c43444300ad0fa058d09bdbd844563086 Mon Sep 17 00:00:00 2001 From: iamBadgers Date: Thu, 9 Apr 2026 18:36:51 -0700 Subject: [PATCH] Messin with some other stuff --- src/game_tables.py | 6 ++++-- src/main.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/game_tables.py b/src/game_tables.py index 1db4c9f..313c178 100644 --- a/src/game_tables.py +++ b/src/game_tables.py @@ -1,6 +1,6 @@ from sqlite3 import Connection, Cursor from database import SmartCursor - +import random class GameTable: _game_table_id: int @@ -39,6 +39,8 @@ class GameTable: def commit(self, cursor): if not self._created: + if self._game_table_id == 0: + self._game_table_id = random.randint(1, 999999999) cursor.execute( """INSERT INTO game_tables (game_table_id, game_table_name, game_table_link, active, docker_id) @@ -67,7 +69,7 @@ class GameTable: self._game_table_id, ), ) - self._updated = False + self._updated = True return @property diff --git a/src/main.py b/src/main.py index 520985e..696fec1 100644 --- a/src/main.py +++ b/src/main.py @@ -3,6 +3,7 @@ import sqlite3 from game_tables import GameService, GameTable from key_tables import KeyService, KeyTable import container_managment +from database import SmartCursor app = Flask(__name__) @@ -48,6 +49,28 @@ def get_tables(): return jsonify([table.toJson() for table in tables]) +@app.route("/api/tables", methods=["POST"]) +def create_table(): + app.logger.info(request.get_json()) + app.logger.info(request.get_json()["table_name"]) + db = get_db() + with SmartCursor(connection=db) as smartCursor: + table = GameTable( + game_table_id=0, + game_table_name=request.get_json()["table_name"], + game_table_link=request.get_json()["table_link"], + active=False, + docker_id=None, + ) + app.logger.info(table._created) + app.logger.info(table._updated) + table.commit(smartCursor) + app.logger.info(table._created) + app.logger.info(table._updated) + db.commit() + return jsonify({}), 200 + + @app.route("/api/tables/") def get_table(table_id): gameService = GameService(get_db())