flask结合bootstrap快速搭建网站

安装flask_bootstrap直接pip install flask_bootstrap
使用
`from flask_bootstrap import Bootstrap

bootstrap = Bootstrap(app)`

bootstrap的base.html文档

{% block doc -%}





{%- block html %}

  

    {%- block head %}

    {% block title %}{{title|default}}{% endblock title %}

 

    {%- block metas %}

    

    {%- endblock metas %}

 

    {%- block styles %}

    

    

    {%- endblock styles %}

    {%- endblock head %}

  

  

    {% block body -%}

    {% block navbar %}

    {%- endblock navbar %}

    {% block content -%}

    {%- endblock content %}

 

    {% block scripts %}

    

    

    {%- endblock scripts %}

    {%- endblock body %}

  

{%- endblock html %}



{% endblock doc -%}

main.py

from flask import Flask, render_template
from flask_bootstrap import Bootstrap

app = Flask(__name__)
bootstrap = Bootstrap(app=app)


@app.route('/')
def hello_world():
    return render_template("home.html")


if __name__ == '__main__':
    app.run(debug=True)

home.html

{% extends 'bootstrap/base.html' %}
{% import 'bootstrap/wtf.html' as wtf %}


{% block title %}一夜{% endblock %}

{#{% block content %}#}
{#    #}
{#{% endblock %}#}
{% block navbar %}
    
{% endblock %}
{% block content%}

Hello, world!

...

Learn more

{% endblock %}

python main.py runserver
flask结合bootstrap快速搭建网站_第1张图片

你可能感兴趣的:(知识点)