From 75dd3ce33182a01f907752708cde3e5bd10c3644 Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Thu, 27 Jun 2019 11:25:40 -0700 Subject: [PATCH] Add HTTP redirection with variable setting example --- examples/redirects.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/redirects.py b/examples/redirects.py index a833f465..f47df8ba 100644 --- a/examples/redirects.py +++ b/examples/redirects.py @@ -29,7 +29,7 @@ def internal_redirection_manual(number: int): @hug.post() -def redirect(redirect_type: hug.types.one_of((None, "permanent", "found", "see_other")) = None): +def redirect(redirect_type: hug.types.one_of(("permanent", "found", "see_other")) = None): """Hug also fully supports classical HTTP redirects, providing built in convenience functions for the most common types. """ @@ -38,3 +38,10 @@ def redirect(redirect_type: hug.types.one_of((None, "permanent", "found", "see_o hug.redirect.to("/sum_two_numbers") else: getattr(hug.redirect, redirect_type)("/sum_two_numbers") + + +@hug.post() +def redirect_set_variables(number: int): + """You can also do some manual parameter setting with HTTP based redirects""" + print("HTTP Redirect set variables {}".format(number)) + hug.redirect.to("/sum_two_numbers?number_1={0}&number_2={0}".format(number))