Skip to content
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

Return RedirectResponse or jinja2Templates' TemplateResponse from an endpoint? #343

Open
fmrib00 opened this issue Aug 14, 2024 · 1 comment

Comments

@fmrib00
Copy link

fmrib00 commented Aug 14, 2024

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 fmrib00 changed the title how do I return RedirectResponse or jinja2Templates' TemplateResponse from an endpoint? Return RedirectResponse or jinja2Templates' TemplateResponse from an endpoint? Aug 14, 2024
@fmrib00
Copy link
Author

fmrib00 commented Sep 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant