Spaces:
Running
Running
comment
Browse files
app.py
CHANGED
|
@@ -3,12 +3,16 @@ from huggingface_hub import list_models
|
|
| 3 |
|
| 4 |
|
| 5 |
def hello(profile: gr.OAuthProfile | None) -> str:
|
|
|
|
|
|
|
| 6 |
if profile is None:
|
| 7 |
return "I don't know you."
|
| 8 |
return f"Hello {profile.name}"
|
| 9 |
|
| 10 |
|
| 11 |
def list_private_models(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> str:
|
|
|
|
|
|
|
| 12 |
if oauth_token is None:
|
| 13 |
return "Please log in to list private models."
|
| 14 |
models = [
|
|
@@ -28,6 +32,7 @@ with gr.Blocks() as demo:
|
|
| 28 |
"\n- https://huggingface.co/docs/hub/spaces-oauth"
|
| 29 |
)
|
| 30 |
gr.LoginButton()
|
|
|
|
| 31 |
m1 = gr.Markdown()
|
| 32 |
m2 = gr.Markdown()
|
| 33 |
demo.load(hello, inputs=None, outputs=m1)
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
def hello(profile: gr.OAuthProfile | None) -> str:
|
| 6 |
+
# ^ expect a gr.OAuthProfile object as input to get the user's profile
|
| 7 |
+
# if the user is not logged in, profile will be None
|
| 8 |
if profile is None:
|
| 9 |
return "I don't know you."
|
| 10 |
return f"Hello {profile.name}"
|
| 11 |
|
| 12 |
|
| 13 |
def list_private_models(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToken | None) -> str:
|
| 14 |
+
# ^ expect a gr.OAuthToken object as input to get the user's token
|
| 15 |
+
# if the user is not logged in, oauth_token will be None
|
| 16 |
if oauth_token is None:
|
| 17 |
return "Please log in to list private models."
|
| 18 |
models = [
|
|
|
|
| 32 |
"\n- https://huggingface.co/docs/hub/spaces-oauth"
|
| 33 |
)
|
| 34 |
gr.LoginButton()
|
| 35 |
+
# ^ add a login button to the Space
|
| 36 |
m1 = gr.Markdown()
|
| 37 |
m2 = gr.Markdown()
|
| 38 |
demo.load(hello, inputs=None, outputs=m1)
|