Flask入门教程
1.11 1.12 1.13 1.14 1.15 目录 简介 前言 第 1 章:准备工作 第 2 章:Hello, Flask! 第 3 章:模板 第 4 章:静态文件 第 5 章:数据库 第 6 章:模板优化 第 7 章:表单 第 8 章:用户认证 第 9 章:测试 第 10 章:组织你的代码 第 11 章:部署上线 小挑战 后记 2 Flask 入门教程 开发实战》的作者,Pallets Team 成员。你可以在我 的个人主页了解更多关于我的信息。 目录 前言 第 1 章:准备工作 第 2 章:Hello, Flask! 第 3 章:模板 第 4 章:静态文件 第 5 章:数据库 第 6 章:模板优化 第 7 章:表单 第 8 章:用户认证 第 9 章:测试 第 10 章:组织你的代码 第 11 章:部署上线 小挑战 后记 版权信息 书名:Flask 上是 Star 数量最多的 Python Web 框架,没有之一。 Flask 是典型的微框架,作为 Web 框架来说,它仅保留了核心功能:请求响应处理 和模板渲染。这两类功能分别由 Werkzeug(WSGI 工具库)完成和 Jinja(模板渲 染库)完成,因为 Flask 包装了这两个依赖,我们暂时不用深入了解它们。 主页 这一章的主要任务就是为我们的程序编写一个简单的主页。主页的 URL0 码力 | 127 页 | 7.62 MB | 1 年前3Flask-RESTful Documentation Release 0.3.10
from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } class TodoDao(object): def __init__(self, todo_id, task): Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response called api.add_resource() 'uri': fields.Url('todo_resource'), 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate an absolute uri that includes the scheme, hostname0 码力 | 42 页 | 84.60 KB | 1 年前3Flask-RESTful Documentation Release 0.3.10
response. from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } class TodoDao(object): def __init__(self, todo_id, task): self.todo_id Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response when you called api.add_resource() 'uri': fields.Url('todo_resource'), 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate an absolute uri that includes the scheme, hostname0 码力 | 39 页 | 212.29 KB | 1 年前3Flask-RESTful Documentation Release 0.3.6
OrderedDict from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } 6 Chapter 1. User’s Guide Flask-RESTful Documentation, Release 0.3.6 class Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response add_resource() 'uri': fields.Url('todo_resource'), 1.4. Output Fields 15 Flask-RESTful Documentation, Release 0.3.6 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate0 码力 | 46 页 | 245.60 KB | 1 年前3Flask-RESTful Documentation Release 0.3.6
from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } class TodoDao(object): def __init__(self, todo_id, task): Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response called api.add_resource() 'uri': fields.Url('todo_resource'), 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate an absolute uri that includes the scheme, hostname0 码力 | 49 页 | 91.90 KB | 1 年前3Flask-RESTful Documentation Release 0.3.7
response. from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } class TodoDao(object): def __init__(self, todo_id, task): self.todo_id Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response when you called api.add_resource() 'uri': fields.Url('todo_resource'), 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate an absolute uri that includes the scheme, hostname0 码力 | 50 页 | 253.09 KB | 1 年前3Flask-RESTful Documentation Release 0.3.8
response. from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } class TodoDao(object): def __init__(self, todo_id, task): self.todo_id Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response when you called api.add_resource() 'uri': fields.Url('todo_resource'), 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate an absolute uri that includes the scheme, hostname0 码力 | 50 页 | 253.64 KB | 1 年前3Flask-RESTful Documentation Release 0.3.8
from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } class TodoDao(object): def __init__(self, todo_id, task): Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response called api.add_resource() 'uri': fields.Url('todo_resource'), 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate an absolute uri that includes the scheme, hostname0 码力 | 55 页 | 93.30 KB | 1 年前3Flask-RESTful Documentation Release 0.3.7
from flask_restful import fields, marshal_with resource_fields = { 'task': fields.String, 'uri': fields.Url('todo_ep') } class TodoDao(object): def __init__(self, todo_id, task): Url & Other Concrete Fields Flask-RESTful includes a special field, fields.Url, that synthesizes a uri for the resource that’s being requested. This is also a good example of how to add data to your response called api.add_resource() 'uri': fields.Url('todo_resource'), 'random': RandomNumber, } By default fields.Url returns a relative uri. To generate an absolute uri that includes the scheme, hostname0 码力 | 55 页 | 93.21 KB | 1 年前3Flask Documentation (1.1.x)
configuration: class Config(object): DEBUG = False TESTING = False DATABASE_URI = 'sqlite:///:memory:' class ProductionConfig(Config): DATABASE_URI = 'mysql://user@localhost/foo' (continues on next page) 80 Chapter database server.""" DEBUG = False TESTING = False DB_SERVER = '192.168.1.56' @property def DATABASE_URI(self): # Note: all caps return 'mysql://user@{}/foo'.format(self.DB_SERVER) class ProductionConfig(Config): 'localhost' DEBUG = True class TestingConfig(Config): DB_SERVER = 'localhost' DEBUG = True DATABASE_URI = 'sqlite:///:memory:' There are many different ways and it’s up to you how you want to manage your0 码力 | 291 页 | 1.25 MB | 1 年前3
共 11 条
- 1
- 2