|
import gradio as gr |
|
import os |
|
|
|
def echo(name, request: gr.Request): |
|
if request: |
|
print("Request headers dictionary:", request.headers) |
|
print("IP address:", request.client.host) |
|
return str(request.headers), str(request.client.host) |
|
|
|
def verify_auth(username, password, request: gr.Request): |
|
if dict(request.headers)['origin'] in os.environ["ORIGIN"]: |
|
return True |
|
elif username=="admin" and password=="admin": |
|
return True |
|
else: |
|
return False |
|
|
|
|
|
io = gr.Interface(echo, "textbox", ["textbox", "textbox"]).launch(auth=verify_auth) |