File size: 736 Bytes
4ba4bbb
 
 
 
 
 
 
 
 
607988f
 
4ba4bbb
 
607988f
4ba4bbb
 
607988f
2a5c982
 
4ba4bbb
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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
@app.get("/")
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")