Spaces:
Sleeping
Sleeping
feat: add gradio markdown support
Browse files
app.py
CHANGED
@@ -16,18 +16,28 @@ logging.info("routes included, creating gradio app")
|
|
16 |
|
17 |
|
18 |
CUSTOM_GRADIO_PATH = "/"
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
]
|
27 |
-
|
28 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
logging.info("mounting gradio app within FastAPI...")
|
30 |
-
app = gr.mount_gradio_app(app,
|
31 |
logging.info("gradio app mounted")
|
32 |
|
33 |
|
|
|
16 |
|
17 |
|
18 |
CUSTOM_GRADIO_PATH = "/"
|
19 |
+
with gr.Blocks() as gradio_app:
|
20 |
+
gr.Markdown(
|
21 |
+
"""
|
22 |
+
# Hello World!
|
23 |
+
|
24 |
+
Start typing below to _see_ the *output*.
|
25 |
+
|
26 |
+
Here a [link](https://huggingface.co/spaces/aletrn/gradio_with_fastapi).
|
27 |
+
""")
|
28 |
+
btn = gr.Button(value="Divide et Impera")
|
29 |
+
btn.click(
|
30 |
+
formatters.request_formatter,
|
31 |
+
inputs=[
|
32 |
+
gr.Textbox(lines=1, placeholder="10", label="write an integer to divide 100; number minor than 1 will raise ZeroDivisionError")
|
33 |
+
],
|
34 |
+
outputs=[
|
35 |
+
gr.Textbox(lines=1, placeholder=None, label="Text Output")
|
36 |
+
]
|
37 |
+
)
|
38 |
+
|
39 |
logging.info("mounting gradio app within FastAPI...")
|
40 |
+
app = gr.mount_gradio_app(app, gradio_app, path=CUSTOM_GRADIO_PATH)
|
41 |
logging.info("gradio app mounted")
|
42 |
|
43 |
|