Flask入门教程时,你也可以使用 --user 选项进行用户安装(即 pip install --user pipenv )。用户安装可以避免破坏全局的包,而且可以避 免对不可信的包使用 sudo pip 导致的潜在安全问题。详情见 Pipenv 文档安装 章节。 第 1 章:准备工作 13 第 2 章:Hello, Flask! 追溯到最初,Flask 诞生于 Armin Ronacher 在 2010 app.config['SECRET_KEY'] = 'dev' # 等同于 app.secret_key = 'dev' 第 7 章:表单 64 提示 这个密钥的值在开发时可以随便设置。基于安全的考虑,在部署时应该设置为 随机字符,且不应该明文写在代码里, 在部署章节会详细介绍。 下面在基模板(base.html)里使用 get_flashed_messages() 函数获取提示消 commit() # 提交数据库会话 flash('Item deleted.') return redirect(url_for('index')) # 重定向回主页 为了安全的考虑,我们一般会使用 POST 请求来提交删除请求,也就是使用表单来 实现(而不是创建删除链接): index.html:删除电影条目表单 第 7 章:表单 690 码力 | 127 页 | 7.62 MB | 1 年前3
Flask-RESTful Documentation
Release 0.3.61": "123 fake street", "line 2": null, "state": "NY", "zip ˓→": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 ˓→nowhere", "line 2": null, "state": "NY", "zip": "10468" (bool) – If enabled, trims whitespace around the argument. • nullable (bool) – If enabled, allows null value in argument. __init__(name, default=None, dest=None, required=False, ignore=False, type=null=False, **kwargs) Allows you to nest one set of fields inside another. See Advanced : Nested Field for more information Parameters • nested (dict) – The dictionary to nest • allow_null (bool) 0 码力 | 46 页 | 245.60 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.61": "123 fake street", "line 2": null, "state": "NY", "zip": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 nowhere", "line 2": null, "state": "NY", "zip": "10468", trim (bool) – If enabled, trims whitespace around the argument. nullable (bool) – If enabled, allows null value in argument. __init__(name, default=None, dest=None, required=False, ignore=False, type=null=False, **kwargs) Allows you to nest one set of fields inside another. See Advanced : Nested Field for more information Parameters: nested (dict) – The dictionary to nest allow_null (bool) 0 码力 | 49 页 | 91.90 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.71": "123 fake street", "line 2": null, "state": "NY", "zip ˓→": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 ˓→nowhere", "line 2": null, "state": "NY", "zip": "10468" (bool) – If enabled, trims whitespace around the argument. • nullable (bool) – If enabled, allows null value in argument. __init__(name, default=None, dest=None, required=False, ignore=False, type=null=False, **kwargs) Allows you to nest one set of fields inside another. See Advanced : Nested Field for more information Parameters • nested (dict) – The dictionary to nest • allow_null (bool) 0 码力 | 50 页 | 253.09 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.81": "123 fake street", "line 2": null, "state": "NY", "zip ˓→": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 ˓→nowhere", "line 2": null, "state": "NY", "zip": "10468" (bool) – If enabled, trims whitespace around the argument. • nullable (bool) – If enabled, allows null value in argument. __init__(name, default=None, dest=None, required=False, ignore=False, type=null=False, **kwargs) Allows you to nest one set of fields inside another. See Advanced : Nested Field for more information Parameters • nested (dict) – The dictionary to nest • allow_null (bool) 0 码力 | 50 页 | 253.64 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.81": "123 fake street", "line 2": null, "state": "NY", "zip": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 nowhere", "line 2": null, "state": "NY", "zip": "10468", argument. nullable (bool [https://docs.python.org/3/library/functions.html#bool]) – If enabled, allows null value in argument. Parameters: Parameters: Parameters: Raises: __init__(name, default=None, dest=None def format(self, value): return unicode(value).title() class fields.Nested(nested, allow_null=False, **kwargs) Allows you to nest one set of fields inside another. See Advanced : Nested Field0 码力 | 55 页 | 93.30 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.71": "123 fake street", "line 2": null, "state": "NY", "zip": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 nowhere", "line 2": null, "state": "NY", "zip": "10468", argument. nullable (bool [https://docs.python.org/3/library/functions.html#bool]) – If enabled, allows null value in argument. Parameters: Parameters: Parameters: Raises: __init__(name, default=None, dest=None def format(self, value): return unicode(value).title() class fields.Nested(nested, allow_null=False, **kwargs) Allows you to nest one set of fields inside another. See Advanced : Nested Field0 码力 | 55 页 | 93.21 KB | 1 年前3
Flask Documentation (1.1.x)NOT NULL, password TEXT NOT NULL ); CREATE TABLE post ( id INTEGER PRIMARY KEY AUTOINCREMENT, author_id INTEGER NOT NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, title TEXT NOT NULL, body body TEXT NOT NULL, FOREIGN KEY (author_id) REFERENCES user (id) ); Add the Python functions that will run these SQL commands to the db.py file: Listing 6: flaskr/db.py def init_db(): db = get_db() through subclassing to change the default behavior of OPTIONS responses. New in version 0.7. make_null_session() Creates a new instance of a missing session. Instead of overriding this method we recommend0 码力 | 291 页 | 1.25 MB | 1 年前3
Flask Documentation (1.1.x)username TEXT UNIQUE NOT NULL, password TEXT NOT NULL ); CREATE TABLE post ( id INTEGER PRIMARY KEY AUTOINCREMENT, author_id INTEGER NOT NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP CURRENT_TIMESTAMP, title TEXT NOT NULL, body TEXT NOT NULL, FOREIGN KEY (author_id) REFERENCES user (id) ); Add the Python functions that will run these SQL commands to the db.py file: flaskr/db.py def init_db(): changed through subclassing to change the default behavior of OPTIONS responses. Changelog make_null_session() Creates a new instance of a missing session. Instead of overriding this method we recommend0 码力 | 428 页 | 895.98 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.101": "123 fake street", "line 2": null, "state": "NY", "zip": "10468", "city": "New York"}, "name": "bob", "shipping_address": {"line 1": "555 nowhere", "line 2": null, "state": "NY", "zip": "10468",0 码力 | 42 页 | 84.60 KB | 1 年前3
共 11 条
- 1
- 2













