-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
105 lines (105 loc) · 27.1 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<!DOCTYPE html><html lang="zh-cn"><head><meta charset="utf-8"><meta name="X-UA-Compatible" content="IE=edge"><title> MarkDown</title><meta name="description" content="A Blog Powered By Hexo"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="short icon" href="/favicon.png"><link rel="stylesheet" href="/css/apollo.css"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600" type="text/css"></head><body><header><a href="/" class="logo-link"><img src="/favicon.png"></a><ul class="nav nav-list"><li class="nav-list-item"><a href="/" target="_self" class="nav-list-link active">BLOG</a></li><li class="nav-list-item"><a href="https://github.com/looching" target="_blank" class="nav-list-link">GITHUB</a></li><li class="nav-list-item"><a href="/atom.xml" target="_self" class="nav-list-link">RSS</a></li></ul></header><section class="container"><ul class="home post-list"><li class="post-list-item"><article class="post-block"><h2 class="post-title"><a href="/2016/05/10/TastyPie-Note-1/" class="post-title-link">TastyPie Note 1</a></h2><div class="post-meta"><div class="post-time">2016年5月10日</div></div><div class="post-content"><h3 id="Flow_Through_The_Request/Response_Cycle"><a href="#Flow_Through_The_Request/Response_Cycle" class="headerlink" title="Flow Through The Request/Response Cycle"></a>Flow Through The Request/Response Cycle</h3><p>Tastypie can be thought of as a set of class-based view that provide the API functionality. All routing/middleware/response-handling aspectss are the same as a typical Django app. Where the differs is in the view itself.</p>
<p>Walking through what a GET request to a list endpoint looks like:</p>
<ul>
<li><p>The <code>Resource.urls</code> are checked by Django’s url resolvers.</p>
</li>
<li><p>On a match for the list view, <code>Resource.wrap_view('dispatch_list')</code> is called. <code>wrap_view</code> provides basic error handling & allows for returning serilized errors.</p>
</li>
<li><p>Because dispatch_list was passed to <code>wrap_view</code>, <code>Resource.dispatch_list</code> is called next. This is a thin wrapper around <code>Resource.dispatch</code>.</p>
</li>
<li><p><code>dispatch</code> does a bunch of havy lifting. It ensures:</p>
<ul>
<li>the requested HTTP method is in <code>allowed_methos</code> (<code>method_check</code>).</li>
<li>the class has a method that can handle the request(<code>get_list</code>)</li>
<li>the user is authenticated(<code>is_authenticated</code>)</li>
<li>the user has no exceeded their throttle(<code>throttle_check</code>).</li>
</ul>
<p>At this point, <code>dispatch</code> actually calls the requested method (<code>get_list</code>).</p>
</li>
<li><p><code>get_list</code> does the actual work of API. It does:</p>
<ul>
<li>A fetch of the available objects via <code>Resource.obj_get_list</code>. In the case of <code>ModelResource</code>, this builds the ORM filters to apply (<code>ModelResource.build_filters</code>). It then gets the <code>QuerySet</code> via <code>ModelResource.get_object_list</code> (which performs <code>Resource.authorized_read_list</code> to possibly limit the set the user can work with) and applies the built filters to it.</li>
<li>It then sorts the objects based on user input (<code>ModelResource.apply_sorting</code>).</li>
<li>Then it paginates the results using the supplied <code>Paginator</code> & pulls out the data to be serialized.</li>
<li>The objects in the page have <code>full_dehydrate</code> applied to each of them, causing Tastypie to traslate the raw object data into the fields the endpoint supports.</li>
<li>Finally, it calls <code>Resource.create_response</code>.</li>
</ul>
</li>
<li><p><code>create_response</code> is a shortcut method that:</p>
<ul>
<li>Determines the desired response format (<code>Resource.determine_format</code>).</li>
<li>Serializes the data given to it in the proper format.</li>
<li>Returns a Django <code>HttpResponse</code> (200 OK) with the serialized data.</li>
</ul>
</li>
<li><p>We bubble back up the call stack to <code>dispatch</code>. The last thing <code>dispatch</code> does is potentially store that a request occured for future throttling (<code>Resource.log_throttled_access</code>) then either returns the <code>HttpResponse</code> or wraps whatever data came back in a response (so Django doesn’t freak out).</p>
</li>
</ul>
</div></article></li><li class="post-list-item"><article class="post-block"><h2 class="post-title"><a href="/2016/05/04/Tastypie/" class="post-title-link">Tastypie</a></h2><div class="post-meta"><div class="post-time">2016年5月4日</div></div><div class="post-content"><h4 id="Resources_in_Tastypie"><a href="#Resources_in_Tastypie" class="headerlink" title="Resources in Tastypie"></a>Resources in Tastypie</h4><p>Resources are the heart of Tastypie. By defining a resource we can actually convert a model into an API stream. The data is automatically converted into API response.</p>
<p>Understanding the process of creating a resource.</p>
<ol>
<li>Import ModelResource from Tastypie.</li>
<li>Import models from services app</li>
<li>Create custom resource by inheriting ModelResource and link app model in inner Meta class of resource. </li>
</ol>
<p>Add API URL in the urls.py of app.</p>
<h4 id="Dehydrating_the_JSON_data"><a href="#Dehydrating_the_JSON_data" class="headerlink" title="Dehydrating the JSON data"></a>Dehydrating the JSON data</h4><p><img src="https://impythonist.files.wordpress.com/2016/04/tastypie_ill.png?w=800" alt="flow"></p>
<p>Dehydration in Tastypie means making alterations before sending data to the client. Suppose we need to send capitalized product names instead of small letters. Now we see two kinds of dehydrate methods.</p>
<h5 id="Dehydrate_field_method"><a href="#Dehydrate_field_method" class="headerlink" title="Dehydrate_field method"></a>Dehydrate_field method</h5><p>This <code>dehydrate_field</code> is uesd to modify field on the response JSON. </p>
<h5 id="Dehydrate_method"><a href="#Dehydrate_method" class="headerlink" title="Dehydrate method"></a>Dehydrate method</h5><p>Dehydrate method is useful for aadding additional fields to bundle (response data). </p>
<p>Similarly using <code>hydrate</code> method we can alter the bundle data which is generated from request at the time of PUT or POST methods.</p>
</div></article></li><li class="post-list-item"><article class="post-block"><h2 class="post-title"><a href="/2016/04/25/Django-Manager-Method/" class="post-title-link">Django Manager Method</a></h2><div class="post-meta"><div class="post-time">2016年4月25日</div></div><div class="post-content"><h4 id="Django_Manager"><a href="#Django_Manager" class="headerlink" title="Django Manager"></a>Django Manager</h4><p>Django 里会为每一个 model 生成一个 Manager,默认名字为 objects,一般情况下对 model 进行的处理都是通过 model.objects.XXX( ) 来进行的。其实是调用了 model 的 manager 的方法,而 manager 之中的方法是 QuerySet 方法的代理,QuerySet 方法是对数据库操作的封装。</p>
<p>eg.</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> django.db <span class="keyword">import</span> models</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Person</span><span class="params">(models.Model)</span>:</span></span><br><span class="line"> ...</span><br><span class="line"> people = models.Manager()</span><br></pre></td></tr></table></figure>
<p>上面这个 model,<code>Person.objects</code>会产生一个<code>AttributeError</code>,但是<code>Person.people</code>就可以正常操作。因为默认的 manager 已经变成 people,objects 这个 manager 没有重新声明,不起作用。</p>
<h4 id="u81EA_u5B9A_u4E49_Manager"><a href="#u81EA_u5B9A_u4E49_Manager" class="headerlink" title="自定义 Manager"></a>自定义 Manager</h4><p>通常需要自定义 manager 的情况有两点:</p>
<ol>
<li>需要修改/扩展 Django 的 manager 方法</li>
<li>需要修改返回的 QuerySet</li>
</ol>
<h4 id="u9ED8_u8BA4_Manager"><a href="#u9ED8_u8BA4_Manager" class="headerlink" title="默认 Manager"></a>默认 Manager</h4><p>如果使用自定义的 manager 需要注意的是,Django 将 model 中定义的第一个 manager 认为是默认 manager,而且 Django 框架中会用到默认 manager。</p>
<p>笨方法是使用自定义 manager 的时候,对于 model 依然提供 objects 这个默认 manager,并放在第一个。</p>
<p>eg.</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">Book</span><span class="params">(models.Model)</span>:</span></span><br><span class="line"> title = models.CharField(max_length=<span class="number">100</span>)</span><br><span class="line"> author = models.CharField(max_length=<span class="number">50</span>)</span><br><span class="line"> </span><br><span class="line"> objects = models.Manager() <span class="comment"># default manager</span></span><br><span class="line"> custom_objects = CustomBOokManager() <span class="comment"># custom manager</span></span><br></pre></td></tr></table></figure>
<p><a href="http://blog.csdn.net/sicofield/article/details/49283751" target="_blank" rel="external">source</a></p>
</div></article></li><li class="post-list-item"><article class="post-block"><h2 class="post-title"><a href="/2016/02/16/Flask-Day-2/" class="post-title-link">Flask Day 2</a></h2><div class="post-meta"><div class="post-time">2016年2月16日</div></div><div class="post-content"><p>To handle web forms we use <a href="http://packages.python.org/Flask-WTF" target="_blank" rel="external">Flask-WTF </a>. So we need to write a config file (file <code>config.py</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">WTF_CSRF_ENABLED = <span class="keyword">True</span></span><br><span class="line">SECRET_KEY = <span class="string">'you-will-never-guess'</span></span><br></pre></td></tr></table></figure>
<p>And then you need to use this config (file <code>app/__init__.py</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask</span><br><span class="line"></span><br><span class="line">app = Flask(__name__)</span><br><span class="line">app.config.from_object(<span class="string">'config'</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> app <span class="keyword">import</span> views</span><br></pre></td></tr></table></figure>
<p>Let’s build a simple form (file <code>app/forms.app</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask.ext.wtf <span class="keyword">import</span> Form</span><br><span class="line"><span class="keyword">from</span> wtforms <span class="keyword">import</span> StringField, BooleanField</span><br><span class="line"><span class="keyword">from</span> wtforms.validators <span class="keyword">import</span> DataRequired</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">LoginForm</span><span class="params">(Form)</span>:</span></span><br><span class="line"> openid = StringField(<span class="string">'openid'</span>, validators=[DataRequired()])</span><br><span class="line"> remember_me = BooleanField(<span class="string">'remember_me'</span>, default=<span class="keyword">False</span>)</span><br></pre></td></tr></table></figure>
<p>The <code>DataRequired()</code> is a validator that checks the field is empty or not.</p>
<p>After that, we need a HTML page to show the form (file <code>app/templates/login.html</code>):</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"><!-- extend from base layout --></span></span><br><span class="line">{% extends "base.html" %}</span><br><span class="line"></span><br><span class="line">{% block content %}</span><br><span class="line"> <span class="tag"><<span class="title">h1</span>></span>Sign In<span class="tag"></<span class="title">h1</span>></span></span><br><span class="line"> <span class="tag"><<span class="title">form</span> <span class="attribute">action</span>=<span class="value">""</span> <span class="attribute">method</span>=<span class="value">"post"</span> <span class="attribute">name</span>=<span class="value">"login"</span>></span></span><br><span class="line"> {{ form.hidden_tag() }}</span><br><span class="line"> <span class="tag"><<span class="title">p</span>></span></span><br><span class="line"> Please enter your OpenID:<span class="tag"><<span class="title">br</span>></span></span><br><span class="line"> {{ form.openid(size=80) }}<span class="tag"><<span class="title">br</span>></span></span><br><span class="line"> <span class="tag"></<span class="title">p</span>></span></span><br><span class="line"> <span class="tag"><<span class="title">p</span>></span>{{ form.remember_me }} Remember Me<span class="tag"></<span class="title">p</span>></span></span><br><span class="line"> <span class="tag"><<span class="title">p</span>></span><span class="tag"><<span class="title">input</span> <span class="attribute">type</span>=<span class="value">"submit"</span> <span class="attribute">value</span>=<span class="value">"Sign In"</span>></span><span class="tag"></<span class="title">p</span>></span></span><br><span class="line"> <span class="tag"></<span class="title">form</span>></span></span><br><span class="line">{% endblock %}</span><br></pre></td></tr></table></figure>
<p>The final step is to code a view function that renders the template and receiving data from form (file <code>app/views.py</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> render_template, flash, redirect</span><br><span class="line"><span class="keyword">from</span> app <span class="keyword">import</span> app</span><br><span class="line"><span class="keyword">from</span> .forms <span class="keyword">import</span> LoginForm</span><br><span class="line"></span><br><span class="line"><span class="comment"># index view function suppressed for brevity</span></span><br><span class="line"></span><br><span class="line">app.route(<span class="string">'/login'</span>, methods=[<span class="string">'GET'</span>, <span class="string">'POST'</span>])</span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">login</span><span class="params">()</span>:</span></span><br><span class="line"> form = LoginForm()</span><br><span class="line"> <span class="keyword">if</span> form.validate_on_submit():</span><br><span class="line"> flash(<span class="string">'Login requested for OpenID="%s", remember_me=%s'</span> %</span><br><span class="line"> (form.openid.data, str(form.remember_me.data)))</span><br><span class="line"> <span class="keyword">return</span> redirect(<span class="string">'/index'</span>)</span><br><span class="line"> <span class="keyword">return</span> render_template(<span class="string">'login.html'</span>, </span><br><span class="line"> title=<span class="string">'Sign In'</span>,</span><br><span class="line"> form=form)</span><br></pre></td></tr></table></figure>
</div></article></li><li class="post-list-item"><article class="post-block"><h2 class="post-title"><a href="/2016/02/15/Flask-Day-1/" class="post-title-link">Flask Day 1</a></h2><div class="post-meta"><div class="post-time">2016年2月15日</div></div><div class="post-content"><h3 id="u201CHello_World_u201D_in_Flask"><a href="#u201CHello_World_u201D_in_Flask" class="headerlink" title="“Hello World” in Flask"></a>“Hello World” in Flask</h3><p>Create a folder named <code>microblog</code> (or whatever you want). Then cd into that folder and run following prompt in terminal:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ python3 -m venv flask</span><br></pre></td></tr></table></figure>
<p>Now you’ll have a folder named <code>flask</code> inside <code>microblog</code>, containing a private version of Python interpreter.</p>
<p>And you should install <strong>flask</strong> and extensions by the commands below:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">$ flask/bin/pip install flask</span><br><span class="line">$ flask/bin/pip install flask-login</span><br><span class="line">$ flask/bin/pip install flask-openid</span><br><span class="line">$ flask/bin/pip install flask-mail</span><br><span class="line">$ flask/bin/pip install flask-sqlalchemy</span><br><span class="line">$ flask/bin/pip install sqlalchemy-migrate</span><br><span class="line">$ flask/bin/pip install flask-whooshalchemy</span><br><span class="line">$ flask/bin/pip install flask-wtf</span><br><span class="line">$ flask/bin/pip install flask-babel</span><br><span class="line">$ flask/bin/pip install guess_language</span><br><span class="line">$ flask/bin/pip install flipflop</span><br><span class="line">$ flask/bin/pip install coverage</span><br></pre></td></tr></table></figure>
<p>After that, let’s create the basic structure for our application: <code>app</code> <code>app/static</code> <code>app/templates</code> <code>tmp</code>.</p>
<ol>
<li><code>app</code> — where the application package is</li>
<li><code>static</code> — stores static files like images, javascripts, and css.</li>
<li><code>templates</code> — where templates will go.</li>
</ol>
<p>Then you can start with <code>__init__.py</code> which should put into app folder (file <code>app/__init__.py</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask</span><br><span class="line"></span><br><span class="line">app = Flask(__name__)</span><br><span class="line"><span class="keyword">from</span> app <span class="keyword">import</span> views</span><br></pre></td></tr></table></figure>
<p>The views are the handlers that response to requests from web browsers or other clients. Each view function is mapped to one or more request URLs.</p>
<p>Let’s see what a views function looks like (file <code>app/views.py</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask</span><br><span class="line"></span><br><span class="line">app = Flask(__name__)</span><br><span class="line"><span class="keyword">from</span> app <span class="keyword">import</span> views</span><br></pre></td></tr></table></figure>
<p>Finally we should create a script to starts up the web server with our application(file <code>run.py</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!flask/bin/python</span></span><br><span class="line"><span class="keyword">from</span> app <span class="keyword">import</span> app</span><br><span class="line">app.run(debug=<span class="keyword">True</span>)</span><br></pre></td></tr></table></figure>
<p>To indicating that is an executable file you need to run this in terminal:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ chmod a+x run.py</span><br></pre></td></tr></table></figure>
<p>Now the file structure should look like:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">microblog\ flask\ <virtual environment files> app\ static\ templates\ __init__.py views.py tmp\ run.py</span><br></pre></td></tr></table></figure>
<p>Then start to write the template (file <code>app/templates/index.html</code>):</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag"><<span class="title">html</span>></span></span><br><span class="line"> </span><br><span class="line"> <span class="tag"><<span class="title">head</span>></span></span><br><span class="line"> <span class="tag"><<span class="title">title</span>></span>{{ title }} - microblog<span class="tag"></<span class="title">title</span>></span></span><br><span class="line"> <span class="tag"></<span class="title">head</span>></span></span><br><span class="line"> </span><br><span class="line"> <span class="tag"><<span class="title">body</span>></span></span><br><span class="line"> <span class="tag"><<span class="title">h1</span>></span>Hello, {{ user.nickname }}!<span class="tag"></<span class="title">h1</span>></span></span><br><span class="line"> <span class="tag"></<span class="title">body</span>></span></span><br><span class="line"> </span><br><span class="line"><span class="tag"></<span class="title">html</span>></span></span><br></pre></td></tr></table></figure>
<p>Now let’s write the view function that uses this template (file <code>app/views.py</code>):</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> render_template</span><br><span class="line"><span class="keyword">from</span> app <span class="keyword">import</span> app</span><br><span class="line"></span><br><span class="line"><span class="decorator">@app.route('/')</span></span><br><span class="line"><span class="decorator">@app.route('/index')</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">index</span><span class="params">()</span>:</span></span><br><span class="line"> user = {<span class="string">'nickname'</span>: <span class="string">'ching'</span>} <span class="comment"># fake user</span></span><br><span class="line"> <span class="keyword">return</span> render_template(<span class="string">'index.html'</span>,</span><br><span class="line"> title=<span class="string">'Home'</span>,</span><br><span class="line"> user=user)</span><br></pre></td></tr></table></figure>
<p><code>render_template</code> function is what we import from Flask framework to render the template. It uses <a href="http://jinja.pocoo.org/" target="_blank" rel="external">Jinja2</a> templating engine.</p>
</div></article></li><li class="post-list-item"><article class="post-block"><h2 class="post-title"><a href="/2016/02/12/first-post/" class="post-title-link">First Post</a></h2><div class="post-meta"><div class="post-time">2016年2月12日</div></div><div class="post-content"><p>This is the very first post I wrote,</p>
<p>with <a href="https://www.typora.io/" target="_blank" rel="external">Typora</a> & <a href="https://hexo.io/" target="_blank" rel="external">Hexo</a>.</p>
</div></article></li></ul></section><footer><div class="paginator"></div></footer><script src="https://cdn.bootcss.com/mathjax/2.5.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></body></html>