test_auth / app.py
InnovisionLLC's picture
Update app.py
d3ea459 verified
raw
history blame contribute delete
833 Bytes
from __future__ import annotations
import gradio as gr
from huggingface_hub import whoami
def hello(profile: gr.OAuthProfile | None) -> str:
print(profile)
if profile is None:
return "I don't know you."
return f"Hello {profile.name}"
def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
if oauth_token is None:
return "Please deploy this on Spaces and log in to list organizations."
print(oauth_token)
org_names = [org["name"] for org in whoami(oauth_token.token)["orgs"]]
id = whoami(oauth_token.token)['id']
print(id)
return f"Your id is {id}."
with gr.Blocks() as demo:
gr.LoginButton()
m1 = gr.Markdown()
m2 = gr.Markdown()
demo.load(hello, inputs=None, outputs=m1)
demo.load(list_organizations, inputs=None, outputs=m2)
demo.launch()