Muthuraja18 commited on
Commit
8e2e1d3
·
verified ·
1 Parent(s): 22b65fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py CHANGED
@@ -961,6 +961,35 @@ def home_page():
961
 
962
  # -------------------------
963
  # PLAY PAGE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964
  # -------------------------
965
  def play_page():
966
  import time, json
 
961
 
962
  # -------------------------
963
  # PLAY PAGE
964
+ def create_game(host=None, topics=None, num_questions=10, auto_close=False, ai_topic=None):
965
+ import uuid
966
+ from datetime import datetime
967
+
968
+ # Generate a unique game ID
969
+ game_id = str(uuid.uuid4())[:8] # short 8-char ID
970
+
971
+ # Build the game dictionary
972
+ game = {
973
+ "game_id": game_id,
974
+ "host": host or "Host",
975
+ "topics": topics or [],
976
+ "num_questions": num_questions,
977
+ "questions": [], # You can populate with your question generator
978
+ "players": [],
979
+ "submissions": {},
980
+ "created_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
981
+ "closed": False,
982
+ "auto_close": auto_close,
983
+ "ai_topic": ai_topic,
984
+ }
985
+
986
+ # Save to your database (Firebase / unified_set)
987
+ games = unified_get("games") or {}
988
+ games[game_id] = game
989
+ unified_set("games", games)
990
+
991
+ return game_id
992
+
993
  # -------------------------
994
  def play_page():
995
  import time, json