Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d4aa5e9

Browse filesBrowse files
committed
update python_flask.py
1 parent 3bb4f7b commit d4aa5e9
Copy full SHA for d4aa5e9

File tree

Expand file treeCollapse file tree

2 files changed

+41
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+41
-12
lines changed
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
### python_flask.py: Flask相关说明
4646

47-
### MyShow: 玩点好玩的--知乎全部话题关系可视化(Docker+Flask+Bootstrap+echarts+uWSGI+Nginx)
47+
### MyShow: 玩点好玩的--知乎全部话题关系可视化
4848
===================================================================================================
4949

5050
### 您可以fork该项目, 并在修改后提交Pull request
Collapse file

‎python_flask.py‎

Copy file name to clipboardExpand all lines: python_flask.py
+40-11Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,53 @@
1717
# =============================================================================================================================
1818

1919
# Flask支持的4种钩子函数
20-
# =================================================================================================
20+
# =============================================================================================================================
2121
# before_first_request: 注册一个函数,在处理第一个请求之前运行。
2222
# before_request: 注册一个函数,在每次请求之前运行。
2323
# after_request: 注册一个函数,如果没有未处理的异常抛出,在每次请求之后运行。
2424
# teardown_request:注册一个函数,即使有未处理的异常抛出,也在每次请求之后运行。
25-
# =================================================================================================
25+
# =============================================================================================================================
26+
27+
# Jinja2模板使用
28+
# =============================================================================================================================
29+
# 渲染模板: render_template("user.html", name=name)
30+
# (1) 变量: {{ name | capitalize }}
31+
# (2) 控制结构:
32+
# {% if user %}
33+
# Hello, {{ user }}!
34+
# {% else %}
35+
# Hello, Stranger!
36+
# {% endif %}
37+
#
38+
# <ul>
39+
# {% for comment in comments %}
40+
# <li>{{ comment }}</li> {% endfor %}
41+
# </ul>
42+
# (3) 宏-类似于函数:
43+
# {% macro render_comment(comment) %}
44+
# <li>{{ comment }}</li>
45+
# {% endmacro %}
46+
#
47+
# <ul>
48+
# {% for comment in comments %}
49+
# {{ render_comment(comment) }}
50+
# {% endfor %}
51+
# </ul>
52+
# =============================================================================================================================
2653

2754
# Jinja2变量过滤器
28-
# =================================================================================================
55+
# =============================================================================================================================
2956
# safe: 渲染值时不转义
3057
# capitalize: 把值的首字母转换成大写,其他字母转换成小写
3158
# lower: 把值转换成小写形式
3259
# upper: 把值转换成大写形式
3360
# title: 把值中每个单词的首字母都转换成大写
3461
# trim: 把值的首尾空格去掉
3562
# striptags: 渲染之前把值中所有的 HTML 标签都删掉
36-
# =================================================================================================
63+
# =============================================================================================================================
3764

3865
# Flask-Bootstrap基模板中定义的块
39-
# =================================================================================================
66+
# =============================================================================================================================
4067
# doc: 整个 HTML 文档
4168
# html_attribs: <html> 标签的属性
4269
# html: <html> 标签中的内容
@@ -49,10 +76,10 @@
4976
# navbar: 用户定义的导航条
5077
# content: 用户定义的页面内容
5178
# scripts: 文档底部的 JavaScript 声明
52-
# =================================================================================================
79+
# =============================================================================================================================
5380

54-
# WTForms支持的HTML标准字段
55-
# =================================================================================================
81+
# WTForms支持的HTML标准字段,注意添加app.config['SECRET_KEY'] = 'hard to guess string'
82+
# =============================================================================================================================
5683
# StringField 文本字段
5784
# TextAreaField 多行文本字段
5885
# PasswordField 密码文本字段
@@ -70,10 +97,10 @@
7097
# SubmitField 表单提交按钮
7198
# FormField 把表单作为字段嵌入另一个表单
7299
# FieldList 一组指定类型的字段
73-
# =================================================================================================
100+
# =============================================================================================================================
74101

75102
# WTForms验证函数
76-
# =================================================================================================
103+
# =============================================================================================================================
77104
# Email 验证电子邮件地址
78105
# EqualTo 比较两个字段的值;常用于要求输入两次密码进行确认的情况
79106
# IPAddress 验证 IPv4 网络地址
@@ -85,9 +112,10 @@
85112
# URL 验证 URL
86113
# AnyOf 确保输入值在可选值列表中
87114
# NoneOf 确保输入值不在可选值列表中
88-
# =================================================================================================
115+
# =============================================================================================================================
89116

90117
# uWSGI配置和nginx配置
118+
# =============================================================================================================================
91119
# uwsgi -s /tmp/uwsgi.sock -w MyShow:app --chmod-socket=666
92120
# server {
93121
# listen 80;
@@ -99,3 +127,4 @@
99127
# include uwsgi_params;
100128
# uwsgi_pass unix:/tmp/uwsgi.sock;
101129
# }
130+
# =============================================================================================================================

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.