shee2205 commited on
Commit
6180ec2
·
verified ·
1 Parent(s): 3b2b6bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -75,11 +75,9 @@ def recent_logs():
75
 
76
  SECRET_CODE = "1234" # Change this!
77
 
78
- def ui(request: gr.Request):
79
- # Check for secret in URL, e.g. ?admin=1234
80
  admin_value = None
81
- if hasattr(request, "query_params"):
82
- # Hugging Face passes query_params as dict of lists
83
  qp = request.query_params
84
  if isinstance(qp, dict):
85
  admin_value = qp.get("admin", [None])[0]
@@ -120,6 +118,6 @@ def ui(request: gr.Request):
120
  )
121
  return demo
122
 
123
- demo = gr.Blocks(fn=ui)
124
  if __name__ == "__main__":
125
- demo.launch()
 
75
 
76
  SECRET_CODE = "1234" # Change this!
77
 
78
+ def ui(request: gr.Request = None):
 
79
  admin_value = None
80
+ if request and hasattr(request, "query_params"):
 
81
  qp = request.query_params
82
  if isinstance(qp, dict):
83
  admin_value = qp.get("admin", [None])[0]
 
118
  )
119
  return demo
120
 
121
+ # Main entry point for Hugging Face Spaces:
122
  if __name__ == "__main__":
123
+ gr.Request.launch(ui)