testcoder-ui commited on
Commit
c19d95e
·
1 Parent(s): 85fe453

Fix: Auto-load user info on page load

Browse files

Problem: Users had to manually click refresh button to see their call counts

Solution: Added demo.load() event to automatically call get_user_info() when page loads

Testing: All features tested and verified:
- ✅ Page auto-loads user info (no manual refresh needed)
- ✅ History tab works correctly
- ✅ Daily limit persistence to HF Dataset
- ✅ All imports and syntax verified

User experience improvement: Users now see their status immediately upon page load

Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -847,8 +847,12 @@ with gr.Blocks(title="Video Model Evaluator") as demo:
847
  outputs=[history_output]
848
  )
849
 
850
- # 页面加载时显示初始提示(不绑定函数,避免 "no backend method" 错误)
851
- # 用户信息会在用户操作时更新
 
 
 
 
852
 
853
  # 添加说明
854
  gr.Markdown("""
 
847
  outputs=[history_output]
848
  )
849
 
850
+ # 页面加载时自动获取用户信息(Gradio会自动注入gr.Request)
851
+ demo.load(
852
+ fn=get_user_info,
853
+ inputs=None,
854
+ outputs=[user_info]
855
+ )
856
 
857
  # 添加说明
858
  gr.Markdown("""