Giter VIP home page Giter VIP logo

Comments (4)

freddyaboulton avatar freddyaboulton commented on July 3, 2024 1

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)

from gradio.

freddyaboulton avatar freddyaboulton commented on July 3, 2024

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 /)?

from gradio.

yjtan0819 avatar yjtan0819 commented on July 3, 2024

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.

from gradio.

pievalentin avatar pievalentin commented on July 3, 2024

Thank you, @freddyaboulton very helpful !

from gradio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.