Handling App Refresh

What I’m trying to do:

Whenever a user refreshes the app, it redirects the user back to the login page because that page was set as the start up form and the URL doesn’t change based on where the user landed. I was wondering if there’s a solution to this problem? Thanks.

What I’ve tried and what’s not working:

Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

Clone link:
share a copy of your app

The short answer is to use the routing functionality of Anvil Extras. That will give you a URL for each form, and allow refreshing to start back on that form. GitHub - anvilistas/anvil-extras

1 Like

thanks a million! I should have go through Anvil Extras before asking the question. :slight_smile:

Maybe another answer is to look at startup modules rather than startup forms
See docs on when your app starts

You can define a startup module with the following code:

import anvil.users
from anvil import open_form

def startup():
    if anvil.users.get_user() is not None:
        open_form("Dashboard")
    else:
        open_form("Login")

if __name__ == "__main__":
    startup()

related questions:

1 Like

Thank you @stucork you’re the hero these days!