remove password
Browse files
app.py
CHANGED
@@ -8,20 +8,24 @@ def check_password(username, password):
|
|
8 |
else:
|
9 |
return False
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
read_key = os.environ.get("HF_TOKEN", None)
|
12 |
|
13 |
if __name__ == "__main__":
|
14 |
client = Client.duplicate("Nauryzbay/deckify_private", hf_token=read_key)
|
15 |
|
16 |
-
func = lambda file, number_of_pages: client.predict(file, number_of_pages)
|
17 |
-
|
18 |
with gr.Blocks() as demo:
|
19 |
file = gr.File(label="Upload PDF")
|
20 |
number_of_pages = gr.Number(label="Number of pages")
|
|
|
21 |
output = gr.Textbox(label="Output")
|
22 |
greet_btn = gr.Button("Generate slides")
|
23 |
-
greet_btn.click(fn=func, inputs=[file, number_of_pages], outputs=output, api_name="greet")
|
24 |
|
25 |
-
demo.queue(
|
26 |
-
demo.launch()
|
27 |
-
#
|
|
|
8 |
else:
|
9 |
return False
|
10 |
|
11 |
+
def func(file, number_of_pages, secret):
|
12 |
+
if secret != os.environ["ACCESS"]:
|
13 |
+
return "Wrong password, please try again"
|
14 |
+
else:
|
15 |
+
client.predict(file, number_of_pages)
|
16 |
+
|
17 |
read_key = os.environ.get("HF_TOKEN", None)
|
18 |
|
19 |
if __name__ == "__main__":
|
20 |
client = Client.duplicate("Nauryzbay/deckify_private", hf_token=read_key)
|
21 |
|
|
|
|
|
22 |
with gr.Blocks() as demo:
|
23 |
file = gr.File(label="Upload PDF")
|
24 |
number_of_pages = gr.Number(label="Number of pages")
|
25 |
+
secret = gr.Textbox(label="Password", type="password")
|
26 |
output = gr.Textbox(label="Output")
|
27 |
greet_btn = gr.Button("Generate slides")
|
28 |
+
greet_btn.click(fn=func, inputs=[file, number_of_pages, secret], outputs=output, api_name="greet")
|
29 |
|
30 |
+
demo.queue(max_size=5)
|
31 |
+
demo.launch()
|
|