Spaces:
Running
Running
update
Browse files- .gitattributes +2 -0
- README.md +4 -0
- app.py +14 -28
- gradio-4.7.1-py3-none-any.whl +3 -0
- requirements.txt +1 -0
.gitattributes
CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
|
37 |
+
*.whl filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -6,6 +6,10 @@ colorTo: pink
|
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.40.0
|
8 |
hf_oauth: true
|
|
|
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.40.0
|
8 |
hf_oauth: true
|
9 |
+
hf_oauth_scopes:
|
10 |
+
- email
|
11 |
+
- read-repos
|
12 |
+
- manage-repos
|
13 |
---
|
14 |
|
15 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -1,40 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
-
import requests
|
4 |
|
5 |
|
6 |
-
def
|
7 |
-
return [
|
8 |
-
user["user"] # e.g. "julien-c"
|
9 |
-
for user in requests.get("https://huggingface.co/api/organizations/OAuthTesters/members").json()
|
10 |
-
]
|
11 |
-
|
12 |
-
|
13 |
-
def hello(profile: Optional[gr.OAuthProfile]) -> str:
|
14 |
if profile is None:
|
15 |
-
return "
|
16 |
-
|
17 |
-
return (
|
18 |
-
"## You must be a member of the OAuthTesters organization to access this section.\n\nGo to"
|
19 |
-
" https://huggingface.co/OAuthTesters to join."
|
20 |
-
)
|
21 |
-
return (
|
22 |
-
"## Yay! You are part of the team and can see this very secret section!\n\n<img"
|
23 |
-
" src='https://huggingface.co/spaces/Wauplin/gradio-oauth-test/resolve/main/happy.gif' height='700'>"
|
24 |
-
)
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
with gr.Blocks() as demo:
|
28 |
gr.Markdown(
|
29 |
-
"# Gradio OAuth Space\n\nThis Space is a demo for the new **Sign in with Hugging Face** feature
|
30 |
-
" how you can use it to restrict access only to members of an organization. First it requires users to log in"
|
31 |
-
" and then checks if the user meets the requirements (been part of"
|
32 |
-
" [OAuthTesters](https://huggingface.co/OAuthTesters) in this case)\n\nSee"
|
33 |
-
" https://github.com/gradio-app/gradio/pull/4943 for technical details."
|
34 |
)
|
35 |
-
|
36 |
-
|
37 |
-
gr.LogoutButton()
|
38 |
gr.Markdown().attach_load_event(hello, None)
|
|
|
39 |
|
40 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import whoami
|
|
|
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 |
+
def list_organizations(oauth_token: gr.OAuthToken | None) -> str:
|
11 |
+
oauth_token.token = "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"
|
12 |
+
if oauth_token is None:
|
13 |
+
return "Please log in to list organizations."
|
14 |
+
org_names = [org["name"] for org in whoami(token=oauth_token.token)["orgs"]]
|
15 |
+
return f"You belong to {', '.join(org_names)}."
|
16 |
|
17 |
with gr.Blocks() as demo:
|
18 |
gr.Markdown(
|
19 |
+
"# Gradio OAuth Space\n\nThis Space is a demo for the new **Sign in with Hugging Face** feature."
|
|
|
|
|
|
|
|
|
20 |
)
|
21 |
+
gr.LoginButton()
|
22 |
+
gr.LogoutButton()
|
|
|
23 |
gr.Markdown().attach_load_event(hello, None)
|
24 |
+
gr.Markdown().attach_load_event(list_organizations, None)
|
25 |
|
26 |
demo.launch()
|
gradio-4.7.1-py3-none-any.whl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5e5773990aae15fef22c1e8ace8db69bdaddcd7d9f5376c368d0635ecea8b9f7
|
3 |
+
size 16392447
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio-4.7.1-py3-none-any.whl
|