-
I used to use @app.before_first_request
def _setup_navigation(app):
app.config['navigation'] = [
{'name': 'Home', 'url': url_for('mysite.home', _external=False)},
{'name': 'About', 'url': url_for('mysite.about', _external=False)},
...
] and then I have a <div class="navbar" id="main-nav">
<ul class="nav navbar-nav">
{% for nav in config.navigation %}
<li><a href="{{ nav.url }}">{{ nav.name }}</a></li>
{% endfor %}
</ul>
</div> But then To get around this, I have just added a Perhaps |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You can set the https://flask.palletsprojects.com/en/2.2.x/appcontext/#manually-push-a-context shows how to push an app context during the factory function. |
Beta Was this translation helpful? Give feedback.
-
It’s unclear to me why you aren't just generating these on each request (using |
Beta Was this translation helpful? Give feedback.
You can set the
SERVER_NAME
tolocalhost:8000
during development.https://flask.palletsprojects.com/en/2.2.x/appcontext/#manually-push-a-context shows how to push an app context during the factory function.