matdmiller commited on
Commit
13d23ee
1 Parent(s): 6ff75c6

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()