Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,10 @@ def echo_load(request: gr.Request):
|
|
| 19 |
print("Query parameters:", dict(request.query_params))
|
| 20 |
user_agent = request.headers["user-agent"]
|
| 21 |
device_type = detect_device(user_agent)
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
with gr.Blocks() as demo:
|
| 25 |
with gr.Row():
|
|
@@ -29,7 +32,10 @@ with gr.Blocks() as demo:
|
|
| 29 |
with gr.Column():
|
| 30 |
js = gr.JSON()
|
| 31 |
tb1 = gr.Textbox()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
submit.click(echo, tb, [js, tb1])
|
| 33 |
-
|
| 34 |
-
demo.load(echo_load, [], [js,tb1])
|
| 35 |
demo.launch()
|
|
|
|
| 19 |
print("Query parameters:", dict(request.query_params))
|
| 20 |
user_agent = request.headers["user-agent"]
|
| 21 |
device_type = detect_device(user_agent)
|
| 22 |
+
if "Mobile" in user_agent or "Android" in user_agent or "iPhone" in user_agent:
|
| 23 |
+
return request.headers, "Mobile Device", gr.Textbox(visible=False), gr.Textbox(visible=True)
|
| 24 |
+
else:
|
| 25 |
+
return request.headers, "Web Browser", gr.Textbox(visible=True), gr.Textbox(visible=False)
|
| 26 |
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
with gr.Row():
|
|
|
|
| 32 |
with gr.Column():
|
| 33 |
js = gr.JSON()
|
| 34 |
tb1 = gr.Textbox()
|
| 35 |
+
|
| 36 |
+
tb2 = gr.Textbox(label='Visible only when you are on a Web-browser')
|
| 37 |
+
tb3 = gr.Textbox(label='Visible only when you are on a Mobile device')
|
| 38 |
+
|
| 39 |
submit.click(echo, tb, [js, tb1])
|
| 40 |
+
demo.load(echo_load, [], [js,tb1, tb2, tb3])
|
|
|
|
| 41 |
demo.launch()
|