InnovisionLLC commited on
Commit
7da0ec0
·
verified ·
1 Parent(s): 9a06bf7

Create app.py

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