d3dname commited on
Commit
6635f2f
·
verified ·
1 Parent(s): 6ff32f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -19
app.py CHANGED
@@ -1,29 +1,26 @@
1
- from fastapi import FastAPI
2
  import gradio as gr
3
-
4
- app = FastAPI()
5
 
6
  def echo(message):
7
  return message
8
 
9
- demo = gr.Interface(
10
- fn=echo,
11
- inputs="text",
12
- outputs="text",
13
- title="Echo App",
14
- description="Enter some text, and I'll echo it back to you!"
15
- )
 
 
 
16
 
17
- app = gr.mount_gradio_app(app, demo, path="/")
18
 
19
  @app.get("/hello")
20
- def hello_world():
21
- return {"message": "Hello, World!"}
22
 
23
- @app.get("/")
24
- def hello_world():
25
- return {"message": "Hello, World!"}
26
 
27
- if __name__ == "__main__":
28
- import uvicorn
29
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
1
  import gradio as gr
2
+ from fastapi import FastAPI
 
3
 
4
  def echo(message):
5
  return message
6
 
7
+ def hello_world():
8
+ return {"message": "Hello, World!"}
9
+
10
+ with gr.Blocks() as demo:
11
+ gr.Markdown("# Echo App")
12
+ with gr.Row():
13
+ input_text = gr.Textbox(label="Input")
14
+ output_text = gr.Textbox(label="Output")
15
+ button = gr.Button("Echo")
16
+ button.click(fn=echo, inputs=input_text, outputs=output_text)
17
 
18
+ app = FastAPI()
19
 
20
  @app.get("/hello")
21
+ async def hello():
22
+ return hello_world()
23
 
24
+ gr.mount_gradio_app(app, demo, path="/")
 
 
25
 
26
+ # Hugging Face Spaces will automatically use this app