Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 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 |
+
gr.LogoutButton()
|
| 18 |
+
m1 = gr.Markdown()
|
| 19 |
+
m2 = gr.Markdown()
|
| 20 |
+
demo.load(hello, inputs=None, outputs=m1)
|
| 21 |
+
demo.load(list_organizations, inputs=None, outputs=m2)
|