tregu0458 commited on
Commit
cc3b33e
·
verified ·
1 Parent(s): f654855

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -1,7 +1,22 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs=gr.LoginButton(), outputs="text")
7
  demo.launch()
 
1
  import gradio as gr
2
+ from huggingface_hub import whoami
3
 
4
+ def hello(profile: gr.OAuthProfile | None) -> str:
5
+ if profile is None:
6
+ return "I don't know you."
7
+ return f"Hello {profile.name}"
8
+
9
+ def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
10
+ if oauth_token is None:
11
+ return "Please log in to list organizations."
12
+ org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
13
+ return f"You belong to {', '.join(org_names)}."
14
+
15
+ with gr.Blocks() as demo:
16
+ gr.LoginButton()
17
+ m1 = gr.Markdown()
18
+ m2 = gr.Markdown()
19
+ demo.load(hello, inputs=None, outputs=m1)
20
+ demo.load(list_organizations, inputs=None, outputs=m2)
21
 
 
22
  demo.launch()