HIMANEESH123 commited on
Commit
f024b22
·
verified ·
1 Parent(s): 8b4658f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -25
app.py CHANGED
@@ -579,31 +579,13 @@ pose_reference_images = {}
579
 
580
  def get_user_id() -> str:
581
  """Get or create user ID for the current session."""
582
- if 'user_id' in session:
583
- return session['user_id']
584
-
585
- user_file = os.path.join(CONFIG['USER_DATA_DIR'], '.user_id')
586
- if os.path.exists(user_file):
587
- try:
588
- with open(user_file, 'r') as f:
589
- uid = f.read().strip()
590
- if uid and os.path.exists(os.path.join(CONFIG['USER_DATA_DIR'], uid)):
591
- session['user_id'] = uid
592
- return uid
593
- except:
594
- pass
595
-
596
- uid = str(uuid.uuid4())
597
- session['user_id'] = uid
598
- os.makedirs(os.path.join(CONFIG['USER_DATA_DIR'], uid), exist_ok=True)
599
-
600
- try:
601
- with open(user_file, 'w') as f:
602
- f.write(uid)
603
- except:
604
- pass
605
-
606
- return uid
607
 
608
 
609
  def get_all_poses() -> List[Dict]:
@@ -892,6 +874,10 @@ def save_custom_pose():
892
  if not pose_id or not reference:
893
  return jsonify({'error': 'Missing pose_id or reference'}), 400
894
 
 
 
 
 
895
  user_id = get_user_id()
896
  logger.info(f"💾 Saving custom pose '{name}' (ID: {pose_id}) for user {user_id[:8]}")
897
 
 
579
 
580
  def get_user_id() -> str:
581
  """Get or create user ID for the current session."""
582
+ # Removed the shared .user_id file fallback – rely solely on session
583
+ if 'user_id' not in session:
584
+ session['user_id'] = str(uuid.uuid4())
585
+ user_dir = os.path.join(CONFIG['USER_DATA_DIR'], session['user_id'])
586
+ os.makedirs(user_dir, exist_ok=True)
587
+ logger.info(f"🆕 New user session: {session['user_id'][:8]}")
588
+ return session['user_id']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
589
 
590
 
591
  def get_all_poses() -> List[Dict]:
 
874
  if not pose_id or not reference:
875
  return jsonify({'error': 'Missing pose_id or reference'}), 400
876
 
877
+ # Validate that the reference has the required 'angles' field
878
+ if 'angles' not in reference:
879
+ return jsonify({'error': 'Invalid reference: missing "angles"'}), 400
880
+
881
  user_id = get_user_id()
882
  logger.info(f"💾 Saving custom pose '{name}' (ID: {pose_id}) for user {user_id[:8]}")
883