<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flask扩展 &#8211; 李辉 / Grey Li</title>
	<atom:link href="https://greyli.com/tag/flask%E6%89%A9%E5%B1%95/feed/" rel="self" type="application/rss+xml" />
	<link>https://greyli.com</link>
	<description>一个编程和写作爱好者的在线记事本</description>
	<lastBuildDate>Thu, 06 Nov 2025 11:36:11 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.26</generator>

<image>
	<url>https://greyli.com/wp-content/uploads/2025/03/avatar-500-compressed-144x144.jpg</url>
	<title>Flask扩展 &#8211; 李辉 / Grey Li</title>
	<link>https://greyli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>使用Flask-Avatars在Flask项目中设置头像</title>
		<link>https://greyli.com/flask-avatars/</link>
		<comments>https://greyli.com/flask-avatars/#comments</comments>
		<pubDate>Sun, 22 Jul 2018 02:58:29 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[Flask]]></category>
		<category><![CDATA[Flask-Avatars]]></category>
		<category><![CDATA[Flask扩展]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=1802</guid>
		<description><![CDATA[Flask-Avatars 大多数Web程序中都会涉及到头像的实现。不同类型的项目，对于头像的需求不同，有些项 [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>Flask-Avatars</h2>
<p>大多数Web程序中都会涉及到头像的实现。不同类型的项目，对于头像的需求不同，有些项目可以直接使用Gravatar提供的头像服务，而有的项目则需要提供自定义头像设置。扩展Flask-Avatars几乎满足了所有常见的头像需求：</p>
<ul>
<li>默认头像</li>
<li>Gravatar头像</li>
<li>Robohash头像</li>
<li>社交网站头像</li>
<li>生成随机图案头像Identicon</li>
<li>图片裁剪头像</li>
</ul>
<p><a href="http://greyli.com/wp-content/uploads/2018/07/Flask-Avatars.png"><img class="alignleft size-full wp-image-1803" src="http://greyli.com/wp-content/uploads/2018/07/Flask-Avatars.png" alt="Flask-Avatars" width="974" height="459" srcset="https://greyli.com/wp-content/uploads/2018/07/Flask-Avatars.png 974w, https://greyli.com/wp-content/uploads/2018/07/Flask-Avatars-150x71.png 150w, https://greyli.com/wp-content/uploads/2018/07/Flask-Avatars-300x141.png 300w, https://greyli.com/wp-content/uploads/2018/07/Flask-Avatars-624x294.png 624w" sizes="(max-width: 974px) 100vw, 974px" /></a></p>
<p>GitHub主页：<a href="https://github.com/greyli/flask-avatars">https://github.com/greyli/flask-avatars</a></p>
<h2>安装与初始化</h2>
<p>使用pip安装：</p>
<pre class="">$ pip install flask-avatars</pre>
<p>像其他扩展类似，你需要实例化从flask_avatars导入的Avatars类，并传入app实例：</p>
<pre class="">from flask_avatars import Avatars

app = Flask(__name__)
avatars = Avatars(app)</pre>
<p><em>如果你使用工厂函数创建程序实例，那么这里也可以不传入程序实例app，在工厂函数中对这个avatars对象调用init_app()方法时再传入app实例。</em></p>
<h2>默认头像</h2>
<p>Flask-Avatars内置了几个默认头像，可以用来作为用户注册后的初始头像，或是作为博客评论者的头像。在模板中调用avatars.default()即可获取URL：</p>
<pre class="">&lt;img src="{{ avatars.default() }}"&gt;</pre>
<p>你可以通过size参数来设置尺寸，默认为m，其他可选值有l和s。实际的调用示例如下所示：<a href="http://greyli.com/wp-content/uploads/2018/07/default.png"><img class="alignleft size-full wp-image-1808" src="http://greyli.com/wp-content/uploads/2018/07/default.png" alt="default avatar" width="770" height="617" srcset="https://greyli.com/wp-content/uploads/2018/07/default.png 770w, https://greyli.com/wp-content/uploads/2018/07/default-150x120.png 150w, https://greyli.com/wp-content/uploads/2018/07/default-300x240.png 300w, https://greyli.com/wp-content/uploads/2018/07/default-624x500.png 624w" sizes="(max-width: 770px) 100vw, 770px" /></a></p>
<p>&nbsp;</p>
<h2>Gravatar</h2>
<p>在模板中调用avatars.gravatar()方法并传入Email散列值即可获取Gravatar（<a href="http://gravatar.com">gravatar.com</a>）的头像URL：</p>
<pre class="">&lt;img src="{{ avatars.gravatar(email_hash) }}"&gt;</pre>
<p>Email散列值可以通过下面的方式获取：</p>
<pre class="">import hashlib

avatar_hash = hashlib.md5(my_email.lower().encode('utf-8')).hexdigest()</pre>
<p>实际的调用示例如下所示：<a href="http://greyli.com/wp-content/uploads/2018/07/gravatar.png"><img class="alignleft size-full wp-image-1809" src="http://greyli.com/wp-content/uploads/2018/07/gravatar.png" alt="gravatar" width="836" height="508" srcset="https://greyli.com/wp-content/uploads/2018/07/gravatar.png 836w, https://greyli.com/wp-content/uploads/2018/07/gravatar-150x91.png 150w, https://greyli.com/wp-content/uploads/2018/07/gravatar-300x182.png 300w, https://greyli.com/wp-content/uploads/2018/07/gravatar-624x379.png 624w" sizes="(max-width: 836px) 100vw, 836px" /></a></p>
<h2>Robohash</h2>
<p>Robohash（<a href="http://robohash.org">robohash.org</a>）是一个生成随机机器人头像的服务（目前Gravatar的默认头像中已经支持这一类型，可以通过将default参数设为robohash获取）。在模板中调用avatars.robohash()并传入随机文本作为参数即可获取Robohash的头像URL：</p>
<pre class="">&lt;img src="{{ avatars.robohash(some_text) }}"&gt;</pre>
<p>实际的调用示例如下所示：</p>
<p><a href="http://greyli.com/wp-content/uploads/2018/07/robohash.png"><img class="alignleft size-full wp-image-1804" src="http://greyli.com/wp-content/uploads/2018/07/robohash.png" alt="robohash" width="754" height="401" srcset="https://greyli.com/wp-content/uploads/2018/07/robohash.png 754w, https://greyli.com/wp-content/uploads/2018/07/robohash-150x80.png 150w, https://greyli.com/wp-content/uploads/2018/07/robohash-300x160.png 300w, https://greyli.com/wp-content/uploads/2018/07/robohash-624x332.png 624w" sizes="(max-width: 754px) 100vw, 754px" /></a></p>
<h2>社交网站头像</h2>
<p>Flask-Avatars通过<a href="http://avatars.io">Avatars.io</a>提供了社交头像获取服务，目前支持Facebook、Twitter、Instagram和Gravatar。通过在模板中调用avatars.social_media()方法并传入用户名（username）即可获取对应的头像URL，通过size参数可以设置尺寸，可选值为small、medium和large：</p>
<pre class="">&lt;img src="{{ avatars.social_media(username) }}"&gt;</pre>
<p>通过platform参数可以设置平台，默认为twitter，可选值为twitter、facebook、instagram和gravatar：</p>
<pre class="">&lt;img src="{{ avatars.social_media(username, platform='facebook') }}"&gt;</pre>
<p>实际的调用示例如下所示：</p>
<p><a href="http://greyli.com/wp-content/uploads/2018/07/avatars.io_.png"><img class="alignleft size-full wp-image-1805" src="http://greyli.com/wp-content/uploads/2018/07/avatars.io_.png" alt="avatars.io" width="835" height="566" srcset="https://greyli.com/wp-content/uploads/2018/07/avatars.io_.png 835w, https://greyli.com/wp-content/uploads/2018/07/avatars.io_-150x102.png 150w, https://greyli.com/wp-content/uploads/2018/07/avatars.io_-300x203.png 300w, https://greyli.com/wp-content/uploads/2018/07/avatars.io_-624x423.png 624w" sizes="(max-width: 835px) 100vw, 835px" /></a></p>
<h2>生成随机图案头像Identicon</h2>
<p>Gravatar服务可能会有不稳定的情况，这种情况下，你可以在本地为用户生成头像（identicon），下面是一个简单的示例：</p>
<pre class="">app.config['AVATARS_SAVE_PATH '] = 'the/path/to/save/avatar'

avatar = Identicon()
filenames = avatar.generate(text=‘一串唯一字符’)</pre>
<p>avatar.generate()会根据传入的随机字符创建三个尺寸（可以通过配置变量AVATARS_SIZE_TUPLE自定义）的头像，保存到指定的位置，并返回三个头像文件名。你可以将这个文件名保存到数据库中，并创建一个视图函数来提供头像文件：</p>
<pre class="">from flask import send_form_directory, current_app

@app.route('/avatars/&lt;path:filename&gt;')
def get_avatar(filename):
    return send_from_directory(current_app.config['AVATARS_SAVE_PATH'], filename)</pre>
<p>实际生成的头像示例如下所示：<a href="http://greyli.com/wp-content/uploads/2018/07/identicon.png"><img class="alignleft wp-image-1810 size-full" src="http://greyli.com/wp-content/uploads/2018/07/identicon.png" alt="identicon" width="726" height="589" srcset="https://greyli.com/wp-content/uploads/2018/07/identicon.png 726w, https://greyli.com/wp-content/uploads/2018/07/identicon-150x122.png 150w, https://greyli.com/wp-content/uploads/2018/07/identicon-300x243.png 300w, https://greyli.com/wp-content/uploads/2018/07/identicon-624x506.png 624w" sizes="(max-width: 726px) 100vw, 726px" /></a></p>
<h2>裁剪头像</h2>
<p>Flask-Avatars基于Jcrop提供了头像裁剪功能，具体步骤可以参考文档中的<a href="https://github.com/greyli/flask-avatars#avatar-crop">相关部分</a>。下面是示例程序中的裁剪页面：<a href="http://greyli.com/wp-content/uploads/2018/07/crop.png"><img class="alignleft size-full wp-image-1806" src="http://greyli.com/wp-content/uploads/2018/07/crop.png" alt="裁剪" width="847" height="704" srcset="https://greyli.com/wp-content/uploads/2018/07/crop.png 847w, https://greyli.com/wp-content/uploads/2018/07/crop-150x125.png 150w, https://greyli.com/wp-content/uploads/2018/07/crop-300x249.png 300w, https://greyli.com/wp-content/uploads/2018/07/crop-624x519.png 624w" sizes="(max-width: 847px) 100vw, 847px" /></a></p>
<p>&nbsp;</p>
<p>裁剪后的结果：<a href="http://greyli.com/wp-content/uploads/2018/07/cropped.png"><img class="alignleft size-full wp-image-1807" src="http://greyli.com/wp-content/uploads/2018/07/cropped.png" alt="裁剪完成" width="847" height="704" srcset="https://greyli.com/wp-content/uploads/2018/07/cropped.png 847w, https://greyli.com/wp-content/uploads/2018/07/cropped-150x125.png 150w, https://greyli.com/wp-content/uploads/2018/07/cropped-300x249.png 300w, https://greyli.com/wp-content/uploads/2018/07/cropped-624x519.png 624w" sizes="(max-width: 847px) 100vw, 847px" /></a></p>
<h2>配置</h2>
<p>Flask-Avatars支持的配置列表如下所示：</p>
<table style="width: 682px;">
<thead>
<tr>
<th style="width: 205px;">配置</th>
<th style="width: 129px;">默认值</th>
<th style="width: 348px;">说明</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 205px;">AVATARS_GRAVATAR_DEFAULT</td>
<td style="width: 129px;">identicon</td>
<td style="width: 348px;">Gravatar默认头像类型</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_SAVE_PATH</td>
<td style="width: 129px;"><code>None</code></td>
<td style="width: 348px;">头像保存路径</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_SIZE_TUPLE</td>
<td style="width: 129px;"><code>(30, 60, 150)</code></td>
<td style="width: 348px;">头像尺寸三元素元组，格式为 <code>(small, medium, large)</code>，用于生成identicon头像和裁剪头像</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_IDENTICON_COLS</td>
<td style="width: 129px;">7</td>
<td style="width: 348px;">Identicon头像一行的色块数量</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_IDENTICON_ROWS</td>
<td style="width: 129px;">7</td>
<td style="width: 348px;">Identicon头像一列的色块数量</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_IDENTICON_BG</td>
<td style="width: 129px;"><code>None</code></td>
<td style="width: 348px;">Identicaon头像的背景颜色，传入RGB元组，比如<code>(125, 125, 125)</code>。默认使用随机颜色</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_CROP_BASE_WIDTH</td>
<td style="width: 129px;">500</td>
<td style="width: 348px;">裁剪图片的显示宽度</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_CROP_INIT_POS</td>
<td style="width: 129px;">(0, 0)</td>
<td style="width: 348px;">裁剪框起始位置，两元素元组(x, y)，默认为左上角</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_CROP_INIT_SIZE</td>
<td style="width: 129px;">None</td>
<td style="width: 348px;"> 裁剪框的尺寸，默认为尺寸元组中设置的l尺寸大小，即<code>AVATARS_SIZE_TUPLE[0]</code></td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_CROP_MIN_SIZE</td>
<td style="width: 129px;">None</td>
<td style="width: 348px;">裁剪框的限制最小尺寸，默认无限制</td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_CROP_PREVIEW_SIZE</td>
<td style="width: 129px;">None</td>
<td style="width: 348px;">预览窗口的尺寸，默认为尺寸元组中设置的m尺寸大小，即<code>AVATARS_SIZE_TUPLE[1]</code></td>
</tr>
<tr>
<td style="width: 205px;">AVATARS_SERVE_LOCAL</td>
<td style="width: 129px;">False</td>
<td style="width: 348px;">是否从本地加载Jcrop资源，默认从CDN加载</td>
</tr>
</tbody>
</table>
<h2>示例程序</h2>
<p>Flask-Avatars的Git仓库中包含三个实例程序，也就是文中的截图对应的程序：</p>
<ul>
<li>examples/basic —— 基本示例</li>
<li>examples/identicon —— Identicon示例</li>
<li>examples/crop —— 裁剪示例</li>
</ul>
<p>你可以通过下面的方式来运行实例程序：</p>
<pre class="">$ git clone https://github.com/greyli/flask-avatars.git
$ cd flask-avatars/examples
$ pip install flask flask-avatars
$ cd basic  # 切换到identicon和crop目录可以运行对应的示例程序
$ flask run</pre>
<p>这篇文章属于“Flask常用扩展介绍系列”，这个系列的文章目录索引可以在<a href="http://greyli.com/flask-extensions/">《Flask常用扩展介绍系列文章索引》</a>看到。</p>
<h2>相关链接</h2>
<ul>
<li>GitHub主页：<a href="https://github.com/greyli/flask-avatars">https://github.com/greyli/flask-avatars</a></li>
<li>Flask常用扩展介绍系列文章索引：<a href="http://greyli.com/flask-extensions/">http://greyli.com/flask-extensions/</a></li>
<li>Gravatar头像API：<a href="https://en.gravatar.com/site/implement/images/">https://en.gravatar.com/site/implement/images/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/flask-avatars/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>使用Bootstrap-Flask在Flask项目中集成Bootstrap</title>
		<link>https://greyli.com/integrate-bootstrap-in-flask-application-with-bootstrap-flask/</link>
		<comments>https://greyli.com/integrate-bootstrap-in-flask-application-with-bootstrap-flask/#comments</comments>
		<pubDate>Sun, 15 Jul 2018 09:41:55 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[Bootstrap]]></category>
		<category><![CDATA[Bootstrap-Flask]]></category>
		<category><![CDATA[Flask]]></category>
		<category><![CDATA[Flask扩展]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=1751</guid>
		<description><![CDATA[Bootstrap-Flask是一个简化在Flask项目中集成前端开源框架Bootstrap过程的Flask扩 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>
	<a href="https://github.com/greyli/bootstrap-flask">Bootstrap-Flask</a>是一个简化在Flask项目中集成前端开源框架<a href="https://getbootstrap.com/">Bootstrap</a>过程的Flask扩展。使用Bootstrap可以快速的创建简洁、美观又功能全面的页面，而Bootstrap-Flask让这一过程更加简单和高效。尤其重要的是，Bootstrap-Flask支持最新版本的Bootstrap 4版本。
</p>
<div id="attachment_1761" style="width: 766px" class="wp-caption alignnone"><img class="size-full wp-image-1761 wp-caption alignnone" src="http://greyli.com/wp-content/uploads/2018/07/bootstrap-flask.png" alt="Bootstrap-Flask logo" width="756" height="209" title="" style="" srcset="https://greyli.com/wp-content/uploads/2018/07/bootstrap-flask.png 756w, https://greyli.com/wp-content/uploads/2018/07/bootstrap-flask-150x41.png 150w, https://greyli.com/wp-content/uploads/2018/07/bootstrap-flask-300x83.png 300w, https://greyli.com/wp-content/uploads/2018/07/bootstrap-flask-624x173.png 624w" sizes="(max-width: 756px) 100vw, 756px" /><p class="wp-caption-text">Bootstrap-Flask logo</p></div>
<p>
	<span data-offset-key="aok4p-0-0">GitHub项目主页：</span><a class="Link ztext-link" data-editable="true" data-offset-key="aok4p-1-0" href="https://github.com/greyli/bootstrap-flask" rel="noopener" target="_blank"><span data-offset-key="aok4p-1-0">https://github.com/greyli/bootstrap-flask</span></a>
</p>
<h2>
	和Flask-Bootstrap的区别<br />
</h2>
<p>
	简单来说，Bootstrap-Flask的出现是为了替代不够灵活且缺乏维护的Flask-Bootstrap。它的主要设计参考了Flask-Bootstrap，其中渲染表单和分页部件的宏基于Flask-Bootstrap中的相关代码修改实现。和Flask-Bootstrap相比，前者有下面这些优点：
</p>
<ul>
<li>
		去掉了内置的基模板，换来更大的灵活性，提供了资源引用代码生成函数
	</li>
<li>
		支持Bootstrap 4
	</li>
<li>
		标准化的Jinja2语法
	</li>
<li>
		提供了更多方便的宏，比如简单的分页导航部件、导航链接等
	</li>
<li>
		宏的功能更加丰富，比如分页导航支持传入URL片段
	</li>
<li>
		统一的宏命名，即&ldquo;render_*&rdquo;，更符合直觉
	</li>
</ul>
<h2>
	安装与初始化<br />
</h2>
<p>
	你如果使用过Flask-Bootstrap，那么除了安装时的名称外，这个过程基本没有不同。
</p>
<p>
	安装：
</p>
<pre>
$ pip install bootstrap-flask
</pre>
<p>
	初始化：
</p>
<pre>
from flask_bootstrap import Bootstrap
from flask import Flask

app = Flask(__name__)

bootstrap = Bootstrap(app)</pre>
<p>
	如果你使用工厂函数创建程序实例，那么可以使用下面的方式初始化扩展：
</p>
<pre>
from flask_bootstrap import Bootstrap
from flask import Flask

bootstrap = Bootstrap()

def create_app():
    app = Flask(__name__)
    bootstrap.init_app(app)
    
    return app
</pre>
<h2>
	Bootstrap-Flask提供了哪些功能<br />
</h2>
<h3>
	2个资源加载函数<br />
</h3>
<p>
	在简单的示例程序中，或是在开发时，你可以使用它提供的两个快捷方法来生成Bootstrap资源引用代码，如下所示：
</p>
<pre>
&lt;head&gt;
{{ bootstrap.load_css() }}
&lt;/head&gt;
&lt;body&gt;
...
{{ bootstrap.load_js() }}
&lt;/body&gt;</pre>
<h3>
	7个快捷渲染宏<br />
</h3>
<p>
	目前，Bootstrap-Flask一共提供了7个宏，分别用来快捷渲染各类Bootstrap页面组件，并提供了对扩展Flask-WTF、Flask-SQLAlchemy的支持。
</p>
<table style="height: 270px;">
<thead>
<tr style="height: 27px;">
<th style="height: 27px;">
				宏
			</th>
<th style="height: 27px;">
				模板路径
			</th>
<th style="height: 27px;">
				说明
			</th>
</tr>
</thead>
<tbody>
<tr style="height: 27px;">
<td style="height: 27px;">
				render_field()
			</td>
<td style="height: 27px;">
				bootstrap/form.html
			</td>
<td style="height: 27px;">
				渲染一个WTForms表单字段
			</td>
</tr>
<tr style="height: 27px;">
<td style="height: 27px;">
				render_form()
			</td>
<td style="height: 27px;">
				bootstrap/form.html
			</td>
<td style="height: 27px;">
				渲染一个WTForms表单类
			</td>
</tr>
<tr style="height: 54px;">
<td style="height: 54px;">
				render_pager()
			</td>
<td style="height: 54px;">
				bootstrap/pagination.html
			</td>
<td style="height: 54px;">
				渲染一个简单分页导航，包含上一页和下一页按钮
			</td>
</tr>
<tr style="height: 27px;">
<td style="height: 27px;">
				render_pagination()
			</td>
<td style="height: 27px;">
				bootstrap/pagination.html
			</td>
<td style="height: 27px;">
				渲染一个标准分页导航部件
			</td>
</tr>
<tr style="height: 27px;">
<td style="height: 27px;">
				render_nav_item()
			</td>
<td style="height: 27px;">
				bootstrap/nav.html
			</td>
<td style="height: 27px;">
				渲染一个导航条目
			</td>
</tr>
<tr style="height: 27px;">
<td style="height: 27px;">
				render_breadcrumb_item()
			</td>
<td style="height: 27px;">
				bootstrap/nav.html
			</td>
<td style="height: 27px;">
				渲染一个面包屑条目
			</td>
</tr>
<tr style="height: 54px;">
<td style="height: 54px;">
				render_static()
			</td>
<td style="height: 54px;">
				bootstrap/utils.html
			</td>
<td style="height: 54px;">
				渲染一个资源引用语句，即&nbsp;<code>&lt;link&gt;</code>或<code>&lt;script&gt;</code>标签语句
			</td>
</tr>
</tbody>
</table>
<p>
	使用方法相当简单，以渲染Flask-WTF（WTForms）的表单类的render_form()宏为例，你只需要从对应的模板路径导入宏，然后调用即可并传入必要的参数：
</p>
<pre>
{% from &#39;bootstrap/form.html&#39; import render_form %}

{{ render_form(form) }}</pre>
<p>
	你可以在项目仓库的examples目录下找到一个完整的示例程序，示例程序的运行方式如下：
</p>
<pre>
$ git clone https://github.com/greyli/bootstrap-flask.git
$ pip install flask flask-wtf flask-sqlalchemy bootstrap-flask
$ cd bootstrap-flask/examples
$ flask run</pre>
<p>
	现在访问http://localhost:5000即可看到示例程序主页。示例程序包含所有宏的实际调用示例，其中分页宏示例页面如下图所示：
</p>
<div id="attachment_1760" style="width: 1033px" class="wp-caption aligncenter"><img class="size-full wp-image-1760 wp-caption aligncenter" src="http://greyli.com/wp-content/uploads/2018/07/分页宏示例.png" alt="分页宏示例" width="1023" height="780" srcset="https://greyli.com/wp-content/uploads/2018/07/分页宏示例.png 1023w, https://greyli.com/wp-content/uploads/2018/07/分页宏示例-150x114.png 150w, https://greyli.com/wp-content/uploads/2018/07/分页宏示例-300x229.png 300w, https://greyli.com/wp-content/uploads/2018/07/分页宏示例-624x476.png 624w" sizes="(max-width: 1023px) 100vw, 1023px" /><p class="wp-caption-text">分页宏示例</p></div>
<h2>
	欢迎贡献代码<br />
</h2>
<p>
	这个项目还刚刚起步，各方面都有需要完善的地方，近期我会为它编写一份完善的文档，欢迎有兴趣的朋友<a href="https://github.com/greyli/bootstrap-flask">贡献代码</a>！</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/integrate-bootstrap-in-flask-application-with-bootstrap-flask/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>
