Messin with some other stuff

This commit is contained in:
iamBadgers
2026-04-09 18:36:51 -07:00
parent 917870128d
commit 69241d1c43
2 changed files with 27 additions and 2 deletions

View File

@@ -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

View File

@@ -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/<table_id>")
def get_table(table_id):
gameService = GameService(get_db())