File size: 502 Bytes
71f7514 c49c5a9 71f7514 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import gradio as gr
import socket
def detect(text, request: gr.Request):
client_ip = request.client.host
local_ip = socket.gethostbyname(socket.gethostname())
return text, {"client_ip": client_ip, "local_ip": local_ip}
with gr.Blocks() as demo:
gr.Markdown("## Test request")
text = gr.Textbox(label="dummy input")
output = gr.JSON({})
btn = gr.Button("Test")
btn.click(predict, inputs=[text],outputs=[text, output])
block.launch(share=False, server_name='0.0.0.0') |