Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
-
import os
|
3 |
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
global auth_value
|
8 |
-
if request:
|
9 |
-
if dict(request.headers)['origin'] in os.environ["ORIGIN"]:
|
10 |
-
auth_value = True
|
11 |
-
print("Request headers dictionary:", request.headers)
|
12 |
-
print("IP address:", request.client.host)
|
13 |
-
return str(request.headers), str(request.client.host)
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
return True
|
20 |
-
elif username == "admin" and password == "admin":
|
21 |
-
auth_value = True
|
22 |
-
return True
|
23 |
-
else:
|
24 |
-
return False
|
25 |
-
|
26 |
|
27 |
-
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
def get_msg(name, request: gr.Request):
|
4 |
+
if dict(request.headers)['origin'] in os.environ["ORIGIN"]:
|
5 |
+
return "Working"
|
6 |
+
return "Hello " + name + "!"
|
7 |
|
8 |
+
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
input = gr.Textbox(label="Prompt", elem_id="textbox")
|
11 |
+
output = gr.Textbox(label="Output", elem_id="textbox")
|
12 |
+
button = gr.Button(value="Make Magic", elem_id="button")
|
13 |
+
button.click(get_msg, inputs=[input], outputs=[output])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
demo.launch()
|