Spaces:
Runtime error
Runtime error
Srinivasulu kethanaboina commited on
Update app.py
Browse files1 unmodified line234567891011121314151617181920211 unmodified lineimport loggingimport gradio as grfrom threading import Threadmy=""app = FastAPI()@app.get("/")async def read_root(request: Request):client_ip = request.client.hostlogging.info(f'Client IP Address: {client_ip}')print(client_ip)my=str(client_ip)return {"Client IP Address": client_ip}def gradio_interface():def greet(name):return f"Hello {name}!{my}"iface = gr.Interface(fn=greet, inputs="text", outputs="text")iface.launch()1 unmodified line234567891011121314151617181920212223242526271 unmodified lineimport loggingimport gradio as grfrom threading import Threadfrom pydantic import BaseModelapp = FastAPI()# Shared state to store the IP addressclass SharedState(BaseModel):client_ip: str = ""shared_state = SharedState()@app.get("/")async def read_root(request: Request):client_ip = request.client.hostlogging.info(f'Client IP Address: {client_ip}')shared_state.client_ip = client_ipreturn {"Client IP Address": client_ip}def gradio_interface():def greet(name):return f"Hello {name}! Last client IP: {shared_state.client_ip}"iface = gr.Interface(fn=greet, inputs="text", outputs="text")iface.launch()
app.py+10-4