aletrn commited on
Commit
32a6c80
·
1 Parent(s): 53b5c95

feat: add gradio markdown support

Browse files
Files changed (1) hide show
  1. app.py +21 -11
app.py CHANGED
@@ -16,18 +16,28 @@ logging.info("routes included, creating gradio app")
16
 
17
 
18
  CUSTOM_GRADIO_PATH = "/"
19
- io = gr.Interface(
20
- formatters.request_formatter,
21
- inputs=[
22
- gr.Textbox(lines=1, placeholder="10", label="write a number to divide 100; 0 will raise ZeroDivisionError"),
23
- ],
24
- outputs=[
25
- gr.Textbox(lines=1, placeholder=None, label="Text Output"),
26
- ],
27
- title="gradio with fastapi...",
28
- )
 
 
 
 
 
 
 
 
 
 
29
  logging.info("mounting gradio app within FastAPI...")
30
- app = gr.mount_gradio_app(app, io, path=CUSTOM_GRADIO_PATH)
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