Introducing Gradio Clients
WatchIntroducing Gradio Clients
WatchNew to Gradio? Start here: Getting Started
See the Release History
To install Gradio from main, run the following command:
pip install https://gradio-builds.s3.amazonaws.com/7e61de7189376dbc10042a791ae0025b8789f3ec/gradio-4.42.0-py3-none-any.whl*Note: Setting share=True in
launch() will not work.
gradio.Request(ยทยทยท)headers, client, query_params, session_hash, and path_params. If auth is enabled, the username attribute can be used to get the logged in user. In some environments, the dict-like attributes (e.g. requests.headers, requests.query_params) of this class are automatically converted to to dictionaries, so we recommend converting them to dictionaries before accessing attributes for consistent behavior in different environments.import gradio as gr
def echo(text, request: gr.Request):
if request:
print("Request headers dictionary:", request.headers)
print("IP address:", request.client.host)
print("Query parameters:", dict(request.query_params))
print("Session hash:", request.session_hash)
return text
io = gr.Interface(echo, "textbox", "textbox").launch()import gradio as gr
def predict(text, request: gr.Request):
headers = request.headers
host = request.client.host
user_agent = request.headers["user-agent"]
return {
"ip": host,
"user_agent": user_agent,
"headers": headers,
}
gr.Interface(predict, "text", "json").launch()