🔗Redirect

Here, we show you how to make a redirect in Expross

Simple redirect

To make a redirect, you can just call the redirect function:


def main():
    app.redirect("https://google.com")
    
app.get("/", main)

Do not ever make an error handler for HTTPFound. This error is being raised so that we can feagure out when you whant a redirect.

An example of a bad redirect usage:

bad_example.py

def bad():
    try:
        app.redirect("https://google.com") 
    except HTTPFound: # Do not ever do this
        pass

Function definition

def redirect(self, location: str):
    """Redirects to the specified location

    Args:
        location (str): Location to be redirected

    Raises:
        HTTPFound (depends on code): A Exception used to redirect user

        Note:
            Please do not do any error handling for this. This is an intentionally
            error to redirect the user.
    """

Last updated