Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
import gradio as gr
|
|
|
|
|
|
|
| 3 |
app = FastAPI()
|
|
|
|
|
|
|
| 4 |
@app.get("/")
|
| 5 |
def read_main():
|
| 6 |
return {"message": "This is your main app"}
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# from fastapi import FastAPI
|
| 2 |
+
# import gradio as gr
|
| 3 |
+
# app = FastAPI()
|
| 4 |
+
# @app.get("/")
|
| 5 |
+
# def read_main():
|
| 6 |
+
# return {"message": "This is your main app"}
|
| 7 |
+
# io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
| 8 |
+
# app = gr.mount_gradio_app(app, io, path="/gradio")
|
| 9 |
+
|
| 10 |
from fastapi import FastAPI
|
| 11 |
import gradio as gr
|
| 12 |
+
|
| 13 |
+
# Create a FastAPI app instance
|
| 14 |
app = FastAPI()
|
| 15 |
+
|
| 16 |
+
# Define a route in FastAPI
|
| 17 |
@app.get("/")
|
| 18 |
def read_main():
|
| 19 |
return {"message": "This is your main app"}
|
| 20 |
+
|
| 21 |
+
# Define a simple Gradio interface
|
| 22 |
+
def greet(name):
|
| 23 |
+
return f"Hello, {name}!"
|
| 24 |
+
|
| 25 |
+
io = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 26 |
+
|
| 27 |
+
# Mount the Gradio app on a specific path in the FastAPI app
|
| 28 |
+
gr.mount_gradio_app(app, io, path="/gradio")
|