Spaces:
Runtime error
Runtime error
File size: 780 Bytes
9a942f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio as gr
block = gr.Blocks()
def predict(text, url_params):
print(url_params)
return ["Hello " + text + "!!", url_params]
get_window_url_params = """
function(text_input, url_params) {
console.log(text_input, url_params);
const params = new URLSearchParams(window.location.search);
url_params = Object.fromEntries(params);
return [text_input, url_params];
}
"""
with block:
url_params = gr.JSON({}, visible=True, label="URL Params")
text_input = gr.Text(label="Input")
text_output = gr.Text(label="Output")
btn = gr.Button("Run")
btn.click(fn=predict, inputs=[text_input, url_params],
outputs=[text_output, url_params], _js=get_window_url_params)
block.launch(debug=True)
|