Closed yjtan0819 closed 3 weeks ago
I have not looked into it but I think this makes sense. When you mount gradio at the root /
, the request to /gradio
will be sent to the gradio app at the root, which does not have a way to fulfill that request.
Does this problem happen if the first app is not mounted at /
? Or if you switch the order of the mounting (first mount at /gradio
then /
)?
The problem does not happen if the first app is not mounted at /
, but it still happens if I switch the order of the mounting.
This is the intended behavior of FastAPI so I will close.
from fastapi import FastAPI
parent = FastAPI()
root = FastAPI()
child = FastAPI()
@root.get("/")
def hello():
return "Hello"
@child.get("/hi")
def hi():
return "hi"
parent.mount("/", root)
parent.mount("/child", child)
if __name__ == "__main__":
import uvicorn
uvicorn.run(parent, port=7860)
I suggest you don't place either app at the root and redirect visitors of the home page to whichever child app you want.
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
parent = FastAPI()
root = FastAPI()
child = FastAPI()
@parent.get("/")
def go_to_root():
return RedirectResponse("/root")
@root.get("/")
def hello():
return "Hello"
@child.get("/")
def hi():
return "hi"
parent.mount("/root", root)
parent.mount("/child", child)
if __name__ == "__main__":
import uvicorn
uvicorn.run(parent, port=7860)
Thank you, @freddyaboulton very helpful !
Describe the bug
I am currently facing an issue when trying to mount two Gradio interfaces using the
gr.mount_gradio_app
function.Here's what I am experiencing:
Have you searched existing issues? ๐
Reproduction
Screenshot
Logs
No response
System Info
Severity
I can work around it