Flask Documentation (1.1.x)the API section. Flask depends on the Jinja [https://www.palletsprojects.com/p/jinja/] template engine and the Werkzeug [https://www.palletsprojects.com/p/werkzeug/] WSGI toolkit. The documentation for Extensions Deploying to a Web Server Tutorial Project Layout Application Setup Define and Access the Database Blueprints and Views Templates Static Files Blog Blueprint Make the Project Installable Test Coverage interested. Design Decisions in Flask The Explicit Application Object The Routing System One Template Engine Micro with Dependencies Thread Locals What Flask is, What Flask is Not HTML/XHTML FAQ History of0 码力 | 428 页 | 895.98 KB | 1 年前3
Flask Documentation (1.1.x)of Flask in detail, with a full reference in the API section. Flask depends on the Jinja template engine and the Werkzeug WSGI toolkit. The documentation for these libraries can be found at: • Jinja documentation extensible. Flask won’t make many decisions for you, such as what database to use. Those decisions that it does make, such as what templating engine to use, are easy to change. Everything else is up to you, so that Flask can be everything you need and nothing you don’t. By default, Flask does not include a database abstraction layer, form validation or anything else where different libraries already exist that0 码力 | 291 页 | 1.25 MB | 1 年前3
Flask入门教程数据库工具 (ORM,即对象关系映射)。借助 SQLAlchemy,你可以通过定义 Python 类来表 示数据库里的一张表(类属性表示表中的字段 / 列),通过对这个类进行各种操作 来代替写 SQL 语句。这个类我们称之为模型类,类中的属性我们将称之为字段。 Flask 有大量的第三方扩展,这些扩展可以简化和第三方库的集成工作。我们下面 将使用一个叫做 Flask-SQLAlchemy 的官方扩展来集成 字典。配置变量的名称必须使用大写,写入配置的语句一般 会放到扩展类实例化语句之前。 下面写入了一个 SQLALCHEMY_DATABASE_URI 变量来告诉 SQLAlchemy 数据库连 接地址: import os # ... app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + os.path. join(app.root_path, 'sqlite:///' else: # 否则使用四个斜线 prefix = 'sqlite:////' app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = prefix + os.path.join(ap p.root_path, 'data.db') app.config['SQLALCHEMY_TRACK_MODIFICATIONS']0 码力 | 127 页 | 7.62 MB | 1 年前3
Flask-RESTful Documentation Release 0.3.10db_get_todo() # Some function that queries the db This example assumes that you have a custom database object (todo) that has attributes name, address, and date_updated. Any additional attributes on __init__(self, **kwargs): # smart_engine is a black box dependency self.smart_engine = kwargs['smart_engine'] def get(self): return self.smart_engine.next_todo() You can inject the required required dependency into TodoNext like so: smart_engine = SmartEngine() api.add_resource(TodoNext, '/next', resource_class_kwargs={ 'smart_engine': smart_engine }) Same idea applies for forwarding args0 码力 | 42 页 | 84.60 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.10return db_get_todo() # Some function that queries the db This example assumes that you have a custom database object (todo) that has attributes name, address, and date_updated. Any additional attributes on TodoNext(Resource): def __init__(self, **kwargs): # smart_engine is a black box dependency self.smart_engine = kwargs['smart_engine'] def get(self): return self.smart_engine.next_todo() You can inject the required dependency dependency into TodoNext like so: smart_engine = SmartEngine() api.add_resource(TodoNext, '/next', resource_class_kwargs={ 'smart_engine': smart_engine }) Same idea applies for forwarding args. 260 码力 | 39 页 | 212.29 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.6return db_get_todo() # Some function that queries the db This example assumes that you have a custom database object (todo) that has attributes name, address, and date_updated. Any additional attributes on TodoNext(Resource): def __init__(self, **kwargs): # smart_engine is a black box dependency self.smart_engine = kwargs['smart_engine'] def get(self): return self.smart_engine.next_todo() You can inject the required dependency dependency into TodoNext like so: smart_engine = SmartEngine() api.add_resource(TodoNext, '/next', resource_class_kwargs={ 'smart_engine': smart_engine }) Same idea applies for forwarding args. 260 码力 | 46 页 | 245.60 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.6db_get_todo() # Some function that queries the db This example assumes that you have a custom database object (todo) that has attributes name, address, and date_updated. Any additional attributes on __init__(self, **kwargs): # smart_engine is a black box dependency self.smart_engine = kwargs['smart_engine'] def get(self): return self.smart_engine.next_todo() You can inject the required required dependency into TodoNext like so: smart_engine = SmartEngine() api.add_resource(TodoNext, '/next', resource_class_kwargs={ 'smart_engine': smart_engine }) Same idea applies for forwarding args0 码力 | 49 页 | 91.90 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.7return db_get_todo() # Some function that queries the db This example assumes that you have a custom database object (todo) that has attributes name, address, and date_updated. Any additional attributes on TodoNext(Resource): def __init__(self, **kwargs): # smart_engine is a black box dependency self.smart_engine = kwargs['smart_engine'] def get(self): return self.smart_engine.next_todo() You can inject the required dependency dependency into TodoNext like so: smart_engine = SmartEngine() api.add_resource(TodoNext, '/next', resource_class_kwargs={ 'smart_engine': smart_engine }) Same idea applies for forwarding args. 260 码力 | 50 页 | 253.09 KB | 1 年前3
Flask-RESTful Documentation
Release 0.3.8return db_get_todo() # Some function that queries the db This example assumes that you have a custom database object (todo) that has attributes name, address, and date_updated. Any additional attributes on TodoNext(Resource): def __init__(self, **kwargs): # smart_engine is a black box dependency self.smart_engine = kwargs['smart_engine'] def get(self): return self.smart_engine.next_todo() You can inject the required dependency dependency into TodoNext like so: smart_engine = SmartEngine() api.add_resource(TodoNext, '/next', resource_class_kwargs={ 'smart_engine': smart_engine }) Same idea applies for forwarding args. 260 码力 | 50 页 | 253.64 KB | 1 年前3
Flask-RESTful Documentation Release 0.3.8db_get_todo() # Some function that queries the db This example assumes that you have a custom database object (todo) that has attributes name, address, and date_updated. Any additional attributes on __init__(self, **kwargs): # smart_engine is a black box dependency self.smart_engine = kwargs['smart_engine'] def get(self): return self.smart_engine.next_todo() You can inject the required required dependency into TodoNext like so: smart_engine = SmartEngine() api.add_resource(TodoNext, '/next', resource_class_kwargs={ 'smart_engine': smart_engine }) Same idea applies for forwarding args0 码力 | 55 页 | 93.30 KB | 1 年前3
共 11 条
- 1
- 2













