Spaces:
Runtime error
Runtime error
Download Passing params.py from bumk766fall2023/ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 791 Bytes
-
https://huggingface.co/spaces/bumk766fall2023/ChatBot/resolve/main/Passing%20params.py
- Command line
-
hf download 'hf://spaces/bumk766fall2023/ChatBot/Passing params.py'
-
curl -L -o 'Passing params.py' https://huggingface.co/spaces/bumk766fall2023/ChatBot/resolve/main/Passing%20params.py
791 Bytes
| import gradio as gr | |
| def echo(params): | |
| print(params) | |
| return params | |
| def get_params(request: gr.Request): | |
| params = request.query_params | |
| ip = request.client.host | |
| return {"params": params, | |
| "ip": ip} | |
| with gr.Blocks() as demo: | |
| #session state, where data persists across multiple submits within a page session | |
| url_params = gr.State() | |
| text_in = gr.Textbox() | |
| text_out = gr.JSON() | |
| btn = gr.Button(value="Get params") | |
| # Listener, "echo" - the function to call when this event is triggered. | |
| btn.click(echo, inputs=[url_params], outputs=[text_out]) | |
| #This listener is triggered when the Blocks initially loads in the browser. | |
| demo.load(get_params, None, url_params, queue=True) | |
| #demo.load(get_params, None, url_params, queue=False) | |
| demo.launch() |