FastUI icon indicating copy to clipboard operation
FastUI copied to clipboard

Return RedirectResponse or jinja2Templates' TemplateResponse from an endpoint?

Open fmrib00 opened this issue 1 year ago • 1 comments

I need to redirect the page to some template HTML pages within a fastui endpoint procedure, for example, I need to show the home template page when home link is clicked. so I tried

@router.get('/home', response_model=FastUI, response_model_exclude_none=True)
def home(request: Request) -> list[AnyComponent]:
    return templates.TemplateResponse(
        name="home.html",
        context={"request": request}
    )

but then I will get

Request Error
Response not valid JSON

I am sure there must be a way to do it; I just didn't do it correctly. I would appreciate any help!

fmrib00 avatar Aug 14 '24 07:08 fmrib00

Is there no way to go to a template HTML page from a FastUI end point? I just wanted to redirect to a login page once logout endpoint is triggered. What is the recommended way to handle login with a customer login page that is based on template? @zboyles

fmrib00 avatar Sep 07 '24 12:09 fmrib00