nbroad commited on
Commit
a7987d0
·
verified ·
1 Parent(s): bfae94d

Upload app_wrapper.py

Browse files
Files changed (1) hide show
  1. app_wrapper.py +27 -0
app_wrapper.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import gradio as gr
5
+
6
+ from app import demo as main_demo
7
+
8
+
9
+ allowed_usernames = os.environ["ALLOWED_USERNAMES"].split(",")
10
+
11
+ def render(profile: gr.OAuthProfile | None) -> dict:
12
+ if profile is None:
13
+ visible = None
14
+ else:
15
+ visible = profile.username in allowed_usernames
16
+
17
+ return gr.Column(visible=visible)
18
+
19
+
20
+ with gr.Blocks() as demo:
21
+ gr.LoginButton()
22
+ with gr.Column(visible=False) as col:
23
+ main_demo.render()
24
+ demo.load(fn=render, outputs=col)
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch(show_api=False)