Skip to content

Commit

Permalink
fixes #478 regression
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Aug 30, 2022
1 parent c62c96d commit cf38785
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion justpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""JustPy is an object-oriented, component based, high-level Python Web Framework that requires no front-end programming"""

from .justpy import *
__version__ = "0.4.1"
__version__ = "0.4.2"
5 changes: 3 additions & 2 deletions justpy/routing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from starlette.routing import Route
from starlette.routing import Route, Match
import typing

class JpRoute(Route):
Expand Down Expand Up @@ -42,7 +42,8 @@ def getFuncForScope(cls,scope):
Callable: the function that is bound to the given path
'''
for _path,route in JpRoute.routesByPath.items():
if route.matches(scope):
match,_matchScope=route.matches(scope)
if match is not Match.NONE:
func_to_run=route.endpoint
return func_to_run
return None
Expand Down
4 changes: 2 additions & 2 deletions tests/test_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
@jp.SetRoute("/bye", name = "bye")
def bye_function(_request):
wp = jp.WebPage()
wp.add(jp.P(text='Hello there!', classes='text-5xl m-2'))
wp.add(jp.P(text='Bye bye!', classes='text-5xl m-2'))
return wp

@jp.SetRoute("/hello", name = "hello")
def hello_function(request):
wp = jp.WebPage()
wp.add(jp.P(text='Hello there!', classes='text-5xl m-2'))
print("request = ", request.url_for("bye"))
#print("request = ", request.url_for("hello_function"))
return wp

class TestRouteAndUrlFor(Basetest):
Expand Down

0 comments on commit cf38785

Please sign in to comment.