Custom Components GalleryNEW
ExploreCustom Components GalleryNEW
ExploreNew to Gradio? Start here: Getting Started
See the Release History
gradio.mount_gradio_app(app, blocks, path, ยทยทยท)
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")
# Then run `uvicorn run:app` from the terminal and navigate to http://localhost:8000/gradio.
Parameter | Description |
---|---|
app fastapi.FastAPI required | The parent FastAPI application. |
blocks gradio.Blocks required | The blocks object we want to mount to the parent app. |
path str required | The path at which the gradio application will be mounted. |
app_kwargs dict[str, Any] | None default: None | Additional keyword arguments to pass to the underlying FastAPI app as a dictionary of parameter keys and argument values. For example, |
auth_dependency Callable[[fastapi.Request], str | None] | None default: None | A function that takes a FastAPI request and returns a string user ID or None. If the function returns None for a specific request, that user is not authorized to access the app (they will see a 401 Unauthorized response). To be used with external authentication systems like OAuth. |