Flask-Bootstrap is an extension that packages Twitter Bootstrap (version 3.3.7.1) into a Flask application, providing template macros and resources without requiring boilerplate code. It simplifies the integration of Bootstrap's CSS and JavaScript components into Flask projects. The project's last release was in January 2017, and it is primarily designed for Bootstrap 3 and has Python 2 classifiers.
Install & Compatibility
Where this runs
tested against v3.3.7.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.645s · 25.7MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 4.1s · import 0.595s · 26MB
24MB installed
● package 24MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
The class is simply `Bootstrap`.
from flask_bootstrap import Bootstrap
Initialize the Flask app and the Bootstrap extension, then create a simple route that renders a template extending `bootstrap/base.html` to inherit Bootstrap's styling and scripts. The `SECRET_KEY` is required by Flask for certain functionalities (e.g., flashed messages).
from flask import Flask, render_template
from flask_bootstrap import Bootstrap
import os
app = Flask(__name__)
app.config['SECRET_KEY'] = os.environ.get('FLASK_SECRET_KEY', 'a_secret_key_for_dev')
bootstrap = Bootstrap(app)
@app.route('/')
def index():
return render_template('index.html')
# To run this, save as app.py and create templates/index.html:
# # templates/index.html
# {% extends "bootstrap/base.html" %}
# {% block title %}My Flask-Bootstrap App{% endblock %}
#
# {% block content %}
# <div class="container">
# <h1>Hello, Flask-Bootstrap!</h1>
# <p>This is a basic Flask application with Bootstrap 3 via Flask-Bootstrap.</p>
# <button type="button" class="btn btn-primary">Primary button</button>
# </div>
# {% endblock %}
if __name__ == '__main__':
app.run(debug=True)
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.