-
Notifications
You must be signed in to change notification settings - Fork 316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to view components when the app is mount in another app. #134
Comments
I have tried the "mount" feature from FastAPI with a simpler example. from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from fastui import FastUI, AnyComponent, prebuilt_html, components as c
subapp = FastAPI()
@subapp.get("/api/", response_model=FastUI, response_model_exclude_none=True)
def index() -> list[AnyComponent]:
return [
c.Page(
components=[
c.Heading(text="Hello World!", level=2),
]
),
]
@subapp.get("/{path:path}")
async def html_landing() -> HTMLResponse:
"""Simple HTML page which serves the React app, comes last as it matches all paths."""
return HTMLResponse(prebuilt_html(title="FastUI Demo"))
app = FastAPI()
app.mount("/sub-app", subapp) When I navigate to the
In this example, the backend doesn't specify or tell any URL but check out the URL that FastUI JavaScript constructed for the I think we should specify the @subapp.get("/{path:path}")
async def html_landing() -> HTMLResponse:
"""Simple HTML page which serves the React app, comes last as it matches all paths."""
return HTMLResponse(prebuilt_html(title="FastUI Demo", entry_point="/sub-app/logic")) And we can put the "entry_point" value in the html body, like this: <body entry_point={entry_point}> FastUI JavaScript can look for the "body" and take the |
👍 to this… we definitely need the option to mount a fastui app inside of another app if that’s not possible today! |
👍 agree that an application mount is the cleanest way to mount the ui onto an existing application, this would have made it a lot easier to add the ui to my existing fastapi application. |
I agree this would be good. PR welcome to support it, otherwise I'll get to it soon. |
Fixed by #176 I believe, I need to try it more, but I think it's done. |
@samuelcolvin I don't think #176 fixed this, when mounting a sub app I still get a The example by @hasansezertasan also does not work (#134 (comment)) Is the setup for a sub app different?
|
try this code,look out api_path_strip params |
If I use one FastAPI app which contains all the FastUI routes and I mount this app in another FastAPI app, I can't access to any components in frontend.
What I'm doing wrong ?
I tried to use root_path parameter of FastAPI but with no success
To reproduce:
The text was updated successfully, but these errors were encountered: