Spaces:
Sleeping
Sleeping
Commit
·
b51c81c
1
Parent(s):
9a0a518
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import fastapi
|
3 |
+
|
4 |
+
def echo(request: fastapi.Request):
|
5 |
+
return request.headers, request.client.host
|
6 |
+
|
7 |
+
with gr.Blocks() as demo:
|
8 |
+
with gr.Column():
|
9 |
+
with gr.Row():
|
10 |
+
with_q = gr.Button(value="Print request with queue")
|
11 |
+
with gr.Row():
|
12 |
+
with_q_headers = gr.JSON()
|
13 |
+
with_q_host = gr.Textbox()
|
14 |
+
with gr.Column():
|
15 |
+
with gr.Row():
|
16 |
+
without_q = gr.Button(value="print request without queue")
|
17 |
+
with gr.Row():
|
18 |
+
without_q_headers = gr.JSON()
|
19 |
+
without_q_host = gr.Textbox()
|
20 |
+
with_q.click(echo, inputs=None, outputs=[with_q_headers, with_q_host], queue=True)
|
21 |
+
without_q.click(echo, inputs=None, outputs=[without_q_headers, without_q_host], queue=False)
|
22 |
+
|
23 |
+
demo.queue().launch()
|