Flask-Copilot

Installation

python -m pip install flask-copilot

Quickstart

  1. Initialize the Copilot extension on your Flask app.
  2. Add URL routes normally. Include navbar_kwargs to register routes to your navbar.
from flask import Flask
from flask_copilot import Copilot

app = Flask(__name__)
copilot = Copilot(app)

@app.route('/', navbar_kwargs={'path': 'Home'})
def index():
    """Render the home page."""
    return render_template('index.html')
  1. Render your navbar using the navbar object automatically injected into your template context.
<ul>
  {% for entry in navbar recursive %}
    <li>
      <a href="{{ entry.url() }}">
        {{ entry.name }}
      </a>
      {% if entry.visible_children|list %}
        <ul class="dropdown">{{ loop(entry.visible_children) }}</ul>
      {% endif %}
    </li>
  {% endfor %}
</ul>

Contents:

Indices and tables