Import streamlit file inside app works upon first load only

I am writing an App which uses url queries to fetch parameters and, depending on the value of a parameter, imports a certain Python file for execution. This works well when first loaded; however, when any kind of action is taken inside the imported python file, the page goes blank.

Does anyone know what I am doing wrong?

import streamlit as st

authorised_apps = {'et': 'file-1', 'bc': 'file-2'}

query = st.experimental_get_query_params()
# st.write(query)

# check that app exists
if "app" in query:
    # check that app is authorised
    if query['app'][0] in authorised_apps:
        # import the requested app
        st.error("The requested app is not authorised!")
    st.error("The query is not correct, it needs to contain the parameter 'app'.")

The idea here is that you can control the file that is executed using URL queries and therefore make the URL book-markable.

I figures it out! Of course import is not reloading. Instead, I used:

exec(open(file + '.py', encoding="utf-8").read())

This seems to work fine now!