Black Lives Matter. Please consider donating to Black Girls Code today.

URL request multiple apps

I am new to flask and dash. I am using multiple apps following instructions here.
The app structure is exactly like the link above under Combining One or More Dash Apps with Existing WSGI Apps section.

In app1 and app2 I need to have access to the url before calling my DB function. I tried multiple possible solutions but I still have the problem. Two main errors I got:

  1. This typically means that you attempted to use functionality that needed
    an active HTTP request. Consult the documentation on testing for
    information about how to avoid this problem.

when I try this:

app = dash.Dash(
    __name__, meta_tags=[{"name": "viewport", "content": "width=device-width"}], requests_pathname_prefix='/app1/'
)
flask_app = Flask(__name__)
with flask_app.app_context():
    owner = request.args.get('admin')
rest of app1.py
  1. dash.exceptions.NoLayoutException: The layout was None at the time that run_server was called. Make sure to set the layout attribute of your application before running the server.

when I use flask.has_request_context() like below:

app = dash.Dash(
    __name__, meta_tags=[{"name": "viewport", "content": "width=device-width"}], requests_pathname_prefix='/app1/'
)
flask_app = Flask(__name__)
if flask.has_request_context():
    owner = request.args.get('admin')
    rest of app1.py