# from fastapi import FastAPI | |
# import gradio as gr | |
# app = FastAPI() | |
# @app.get("/") | |
# def read_main(): | |
# return {"message": "This is your main app"} | |
# io = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox") | |
# app = gr.mount_gradio_app(app, io, path="/gradio") | |
from fastapi import FastAPI | |
import gradio as gr | |
# Create a FastAPI app instance | |
app = FastAPI() | |
# Define a route in FastAPI | |
def read_main(): | |
return {"message": "This is your main app"} | |
# Define a simple Gradio interface | |
def greet(name): | |
return f"Hello, {name}!" | |
io = gr.Interface(fn=greet, inputs="text", outputs="text") | |
# Mount the Gradio app on a specific path in the FastAPI app | |
gr.mount_gradio_app(app, io, path="/gradio") | |