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

[BUG] FastHTML by Example should use a redirect for POST instead of render #389

Open
4 tasks done
zdrummond opened this issue Sep 2, 2024 · 0 comments
Open
4 tasks done
Labels
bug Something isn't working

Comments

@zdrummond
Copy link

Describe the bug
This is more a "bug"/question about the tutorial. I was following along and noticed when I got to the WebPage->Web App section that things did not work in the browser.

  1. There seemed to be some loop (that I can not repo) that caused the page to keep adding the last item I submitted
  2. After you add an items and get back to the home page, if you refresh the page it wants to do another form submission

Feels like both issues are because the POST renders the home page instead of redirecting

@app.post("/")
def add_message(data:str):
    messages.append(data)
    return home()

vs

@app.post("/")
def add_message(data: str):
    messages.append(data)
    return RedirectResponse("/", status_code=302)

Expected behavior
If I am follow a demo, the demo produces best practice web patterns. I had to go looking through GitHub example repos to even find that RedirectResponse is the right way to do this.

Environment Information
Please provide the following version information:

  • fastlite version: "0.0.9"
  • fastcore version:"1.7.3"
  • fasthtml version:"0.5.1"

Confirmation
Please confirm the following:

  • I have read the FAQ (https://docs.fastht.ml/explains/faq.html)
  • I have provided a minimal reproducible example
  • I have included the versions of fastlite, fastcore, and fasthtml
  • I understand that this is a volunteer open source project with no commercial support.

Additional context
Note: problem #1 might have been because I was using an earlier version of fasthtml and recently updated, but #2 to exists still.

@zdrummond zdrummond added the bug Something isn't working label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant