Spaces:
Sleeping
Sleeping
mrfakename
commited on
Commit
•
5e86c79
1
Parent(s):
8cd3c8e
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
def hello(profile: gr.OAuthProfile | None) -> str:
|
3 |
+
if profile is None:
|
4 |
+
return "I don't know you."
|
5 |
+
return f"Hello {profile.name}"
|
6 |
+
def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
|
7 |
+
if oauth_token is None:
|
8 |
+
return "Please log in to list organizations."
|
9 |
+
org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
|
10 |
+
return f"You belong to {', '.join(org_names)}."
|
11 |
+
|
12 |
+
|
13 |
+
with gr.Blocks() as demo:
|
14 |
+
gr.LoginButton()
|
15 |
+
gr.LogoutButton()
|
16 |
+
m1 = gr.Markdown()
|
17 |
+
m2 = gr.Markdown()
|
18 |
+
demo.load(hello, inputs=None, outputs=m1)
|
19 |
+
demo.load(list_organizations, inputs=None, outputs=m2)
|