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] Route Content Not Updating When Redefined with Different Function Name in Jupyter Notebook #628

Open
4 tasks done
Zaseem-BIsquared opened this issue Jan 8, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Zaseem-BIsquared
Copy link

Description

When attempting to redefine the same route in Jupyter Notebook using a different function name, such as specifying the HTTP verb (get()) and the route (change()), the content of the route does not update as expected.

Issue

When running the following code in a cell, the browser correctly displays "Change is good!":

@rt("/change")
def get():
    return P("Change is good!")

However, when I attempt to redefine the same route with the function name matching the route in the next cell, as shown below, the browser still displays "Change is good!" instead of the updated content:

@rt("/change")
def change():
    return P("Change is better! - Without specifying the HTTP verb as 'get()'")

I checked the app.routes to investigate the issue, and I found that the "/change" route is being registered twice with the same method (GET), as shown in the output:

[Route(path='/', name='get', methods=['GET', 'HEAD']),
 Route(path='/change', name='get', methods=['GET', 'HEAD']),
 Route(path='/change', name='change', methods=['GET', 'HEAD', 'POST'])]

Expected Behavior

The route should pick the most recently defined handler for the route /change instead of retaining the previous one. The issue may be that duplicate routes with the same method (GET) are not being handled correctly.

Is this behavior expected, or is this a bug?

Environment Information

Please provide the following version information:

  • fastlite version: 0.1.1
  • fastcore version: 1.7.28
  • fasthtml version: 0.11.0

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.
@Zaseem-BIsquared Zaseem-BIsquared added the bug Something isn't working label Jan 8, 2025
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