|
|
@ -46,11 +46,11 @@ def create_game(): |
|
|
|
if 'bots' in request.json: |
|
|
|
bots = request.json.get('bots') |
|
|
|
|
|
|
|
game_count = 0 |
|
|
|
try: |
|
|
|
with sqlite3.connect("database.db") as con: |
|
|
|
# check free port |
|
|
|
port = START_PORT |
|
|
|
game_count = 0 |
|
|
|
cur = con.cursor() |
|
|
|
cur.execute("SELECT * FROM games WHERE port=?", (port,)) |
|
|
|
rows = cur.fetchall() |
|
|
@ -61,7 +61,6 @@ def create_game(): |
|
|
|
rows = cur.fetchall() |
|
|
|
|
|
|
|
if game_count >= MAX_GAMES: |
|
|
|
abort(401) |
|
|
|
return |
|
|
|
|
|
|
|
print("debug: " + str(game_count)) |
|
|
@ -103,6 +102,9 @@ def create_game(): |
|
|
|
abort(500) |
|
|
|
finally: |
|
|
|
con.close() |
|
|
|
if game_count >= MAX_GAMES: |
|
|
|
abort(401) |
|
|
|
return "" |
|
|
|
return jsonify({'name': name, 'port': port}) |
|
|
|
|
|
|
|
|
|
|
|