Redirect User From Server

User is on a “normal” web page and submits a form to an Anvil http endpoint.
How do I then redirect the user to an Anvil form?

The endpoint is of course on the server, so do i have to compose a “redirect” HTTP header and return that to the user, or is there a better (or more “Anvilic”) way?

EDIT -
solved. Here’s some example code for the redirection of the user from an API function :

@anvil.server.http_endpoint("/api_test")
def api_test():
    # Set the response code.
    response = anvil.server.HttpResponse(302, "Redirecting ...")

    # Set the location URL (seems you can't set it to an outside URL?)
    response.headers['Location']=anvil.server.get_app_origin()
    
    # Return the response for the browser to act on.
    return response
1 Like