1.flask-bootstrap
(1)安装flask-bootstrap
pip install flask-bootstrap
(2)flask-bootstrap简单使用
创建bootstrap对象并初始化,构造简单的路由跟视图函数
from flask import Flask,render_template
from flask_bootstrap import Bootstrap
from flask_script import Manager
flask = Flask(__name__)
manager = Manager(flask)
bootstrap = Bootstrap(flask)
@flask.route('/')
def index():
return render_template('base.html')
if __name__ == '__main__':
manager.run()
通过bootstrap构造一个简单的html页面
包括加载静态资源文件
{% extends 'bootstrap/base.html' %}
{% block title %}
bootstrap标题
{% endblock %}
{% block head %}
{
{ super() }}
<link rel="icon" type="image/x-icon" href="{
{ url_for('static',filename='favicon.ico') }}" />
{% endblock %}
{% block navbar %}
<ul class="nav nav-pills">
<li role="presentation" class="active"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Messages&