Introducing Gradio Clients

Watch
  1. Routes
  2. mount_gradio_app

New to Gradio? Start here: Getting Started

See the Release History

To install Gradio from main, run the following command:

pip install https://gradio-builds.s3.amazonaws.com/02798ec170be7c9e8756dec24ef29c7f46fe2060/gradio-4.41.0-py3-none-any.whl

*Note: Setting share=True in launch() will not work.

mount_gradio_app

gradio.mount_gradio_app(···)

Description

Mount a gradio.Blocks to an existing FastAPI application.

Example Usage

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.

Initialization

Parameters