Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
|
|
|
4 |
|
5 |
def echo(name, request: gr.Request):
|
|
|
6 |
if request:
|
7 |
if dict(request.headers)['origin'] in os.environ["ORIGIN"]:
|
8 |
-
|
9 |
print("Request headers dictionary:", request.headers)
|
10 |
print("IP address:", request.client.host)
|
11 |
return str(request.headers), str(request.client.host)
|
12 |
|
13 |
def verify_auth(username, password):
|
14 |
-
|
|
|
15 |
return True
|
16 |
-
elif username=="admin" and password=="admin":
|
|
|
17 |
return True
|
18 |
else:
|
19 |
return False
|
20 |
|
21 |
|
22 |
-
io = gr.Interface(echo, "textbox", ["textbox", "textbox"]).launch(auth=verify_auth)
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
|
4 |
+
auth_value = False
|
5 |
|
6 |
def echo(name, request: gr.Request):
|
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 |
def verify_auth(username, password):
|
16 |
+
global auth_value
|
17 |
+
if auth_value == True:
|
18 |
return True
|
19 |
+
elif username == "admin" and password == "admin":
|
20 |
+
auth_value = True
|
21 |
return True
|
22 |
else:
|
23 |
return False
|
24 |
|
25 |
|
26 |
+
io = gr.Interface(echo, "textbox", ["textbox", "textbox"]).launch(auth=verify_auth)
|