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

provide function castAsEndPoint to hook justpy webpage returning function as Starlette endpoint #532

Closed
sandeep-gh opened this issue Sep 14, 2022 · 2 comments
Assignees
Labels
core enhancement New feature or request
Milestone

Comments

@sandeep-gh
Copy link

CastAsEndpoint would provide a wrapper around justpy endpoint function (which returns a webpage class) to create a function
that returns a Starlette response. The function would act as endpoint for the provided pathglob.

@WolfgangFahl WolfgangFahl added this to the 0.9 milestone Sep 14, 2022
@WolfgangFahl
Copy link
Collaborator

We already have a decorator "reponse" for this now.

@WolfgangFahl WolfgangFahl added the enhancement New feature or request label Sep 14, 2022
@WolfgangFahl
Copy link
Collaborator

@jp.app.route("/greet/{name}")
@jp.app.response
def greeting_function(request):
    wp = jp.WebPage()
    name = f"""{request.path_params["name"]}"""
    wp.add(jp.P(text=f"Hello there, {name}!", classes="text-5xl m-2"))
    return wp

@jp.app.jproute("/bye")
def bye_function(_request):
    wp = jp.WebPage()
    wp.add(jp.P(text="Bye bye!", classes="text-5xl m-2"))
    return wp

the next step will be to make the legacy SetRoute work again as per #502

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants