Spaces:
Sleeping
Sleeping
Ben Burtenshaw
commited on
Commit
·
c838896
1
Parent(s):
a89e8f6
add token
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import whoami
|
3 |
|
|
|
4 |
log_file = "out-file.txt"
|
5 |
|
6 |
|
@@ -24,19 +27,16 @@ def run():
|
|
24 |
yield content
|
25 |
|
26 |
|
27 |
-
|
28 |
-
|
29 |
def hello(profile: gr.OAuthProfile | None) -> str:
|
30 |
if profile is None:
|
31 |
return "I don't know you."
|
32 |
return f"Hello {profile.name}"
|
33 |
|
34 |
|
35 |
-
def
|
36 |
if oauth_token is None:
|
37 |
-
return "Please log in
|
38 |
-
|
39 |
-
return f"You belong to {', '.join(org_names)}."
|
40 |
|
41 |
|
42 |
with gr.Blocks() as demo:
|
@@ -44,7 +44,7 @@ with gr.Blocks() as demo:
|
|
44 |
m1 = gr.Markdown()
|
45 |
m2 = gr.Markdown()
|
46 |
demo.load(hello, inputs=None, outputs=m1)
|
47 |
-
demo.load(
|
48 |
|
49 |
button = gr.Button("Run pipeline")
|
50 |
output = gr.Code(label="Terminal output", interactive=False)
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import gradio as gr
|
4 |
from huggingface_hub import whoami
|
5 |
|
6 |
+
|
7 |
log_file = "out-file.txt"
|
8 |
|
9 |
|
|
|
27 |
yield content
|
28 |
|
29 |
|
|
|
|
|
30 |
def hello(profile: gr.OAuthProfile | None) -> str:
|
31 |
if profile is None:
|
32 |
return "I don't know you."
|
33 |
return f"Hello {profile.name}"
|
34 |
|
35 |
|
36 |
+
def set_token(oauth_token: gr.OAuthToken | None) -> str:
|
37 |
if oauth_token is None:
|
38 |
+
return "Please log in."
|
39 |
+
os.environ["HF_TOKEN"] = oauth_token.token
|
|
|
40 |
|
41 |
|
42 |
with gr.Blocks() as demo:
|
|
|
44 |
m1 = gr.Markdown()
|
45 |
m2 = gr.Markdown()
|
46 |
demo.load(hello, inputs=None, outputs=m1)
|
47 |
+
demo.load(set_token, inputs=None, outputs=m2)
|
48 |
|
49 |
button = gr.Button("Run pipeline")
|
50 |
output = gr.Code(label="Terminal output", interactive=False)
|