Flask Documentation (1.1.x)
Support Template Rendering Configuration Stream Helpers Useful Internals Signals Class-Based Views URL Route Registrations View Function Options Command Line Interface Additional Notes Design notes, legal Flask application looks something like this: from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' So what did that code do? 1. First we imported files, and so on. For more information have a look at the Flask documentation. 3. We then use the route() decorator to tell Flask what URL should trigger our function. 4. The function is given a name0 码力 | 428 页 | 895.98 KB | 1 年前3Flask Documentation (1.1.x)
Flask application looks something like this: from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' So what did that code do? 1. First we imported the files, and so on. For more information have a look at the Flask documentation. 3. We then use the route() decorator to tell Flask what URL should trigger our function. 4. The function is given a name which remember and use to directly visit a page. Use the route() decorator to bind a function to a URL. @app.route('/') def index(): return 'Index Page' @app.route('/hello') (continues on next page) 10 Chapter0 码力 | 291 页 | 1.25 MB | 1 年前3Flask入门教程
。当用户访问根地址的时候,我们需要返回一行欢迎文字。这个任 务只需要下面几行代码就可以完成: app.py:程序主页 from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Welcome to My Watchlist!' 按照惯例,我们把程序保存为 app.py,确保当前目录是项目的根目录,然后在命令 所谓的“注册”,就是给这个函数戴上一个装饰器帽子。我们使用 app.route() 装 饰器来为这个函数绑定对应的 URL,当用户在浏览器访问这个 URL 的时候,就会 触发这个函数,获取返回值,并把返回值显示到浏览器窗口: @app.route('/') def hello(): return 'Welcome to My Watchlist!' 填入 app.route() 装饰器的第一个参数是 URL 修改视图函数返回值 首先,你可以自由修改视图函数的返回值,比如: @app.route('/') def hello(): return u'欢迎来到我的 Watchlist!' 返回值作为响应的主体,默认会被浏览器作为 HTML 格式解析,所以我们可以添加 一个 HTML 元素标记: @app.route('/') def hello(): return 'Hello
0 码力 | 127 页 | 7.62 MB | 1 年前3Celery 2.0 Documentation
traffic. Rate limits can be set for each task type, or globally for all. Routing Using AMQP you can route tasks arbitrarily to different workers. Remote- control You can rate limit and delete (revoke) tasks addition, it also uses the task_id keyword argument to use the same task id, and delivery_info to route the retried task to the same destination. Using a custom retry delay When a task is to be retried meout=3) 2.2.5 Routing options Celery uses the AMQP routing mechanisms to route tasks to different workers. You can route tasks using the following entities: exchange, queue and routing key. Messages0 码力 | 165 页 | 492.43 KB | 1 年前3Celery 2.0 Documentation
traffic. Rate limits can be set for each task type, or globally for all. Routing Using AMQP you can route tasks arbitrarily to different workers. Remote-control You can rate limit and delete (revoke) tasks addition, it also uses the task_id keyword argument to use the same task id, and delivery_info to route the retried task to the same destination. Using a custom retry delay When a task is to be retried get_publisher(connect_timeout=3) Routing options Celery uses the AMQP routing mechanisms to route tasks to different workers. You can route tasks using the following entities: exchange, queue and routing key. Messages0 码力 | 284 页 | 332.71 KB | 1 年前3Celery 2.1 Documentation
traffic. Rate limits can be set for each task type, or globally for all. Routing Using AMQP you can route tasks arbitrarily to different workers. Remote-control You can rate limit and delete (revoke) tasks addition, it also uses the task_id keyword argument to use the same task id, and delivery_info to route the retried task to the same destination. Using a custom retry delay When a task is to be retried add.get_publisher(connect_timeout=3) Routing options Celery uses the AMQP routing mechanisms to route tasks to different workers. Messages (tasks) are sent to exchanges, a queue binds to an exchange0 码力 | 463 页 | 861.69 KB | 1 年前3Celery 2.1 Documentation
traffic. Rate limits can be set for each task type, or globally for all. Routing Using AMQP you can route tasks arbitrarily to different workers. Remote- control You can rate limit and delete (revoke) tasks addition, it also uses the task_id keyword argument to use the same task id, and delivery_info to route the retried task to the same destination. Using a custom retry delay When a task is to be retried get_publisher(connect_timeout=3) 2.3.6 Routing options Celery uses the AMQP routing mechanisms to route tasks to different workers. Messages (tasks) are sent to exchanges, a queue binds to an exchange0 码力 | 285 页 | 1.19 MB | 1 年前3Celery 2.3 Documentation
set for each task type, or globally for all. Routing Using AMQP’s flexible routing model you can route tasks to different workers, or select different message topologies, by configuration or even at runtime Release 2.3.5 try: return self.users[username] == password except KeyError: return False And you route every request to the same process, then it will keep state between requests. This can also be useful get_publisher(connect_timeout=3) 2.3.6 Routing options Celery uses the AMQP routing mechanisms to route tasks to different workers. Messages (tasks) are sent to exchanges, a queue binds to an exchange0 码力 | 334 页 | 1.25 MB | 1 年前3Celery 2.2 Documentation
set for each task type, or globally for all. Routing Using AMQP’s flexible routing model you can route tasks to different workers, or select different message topologies, by configuration or even at runtime add.get_publisher(connect_timeout=3) Routing options Celery uses the AMQP routing mechanisms to route tasks to different workers. Messages (tasks) are sent to exchanges, a queue binds to an exchange use this configuration: CELERY_ROUTES = {"feed.tasks.import_feed": {"queue": "feeds"}} With this route enabled import feed tasks will be routed to the “feeds” queue, while all other tasks will be routed0 码力 | 505 页 | 878.66 KB | 1 年前3Celery 2.3 Documentation
set for each task type, or globally for all. Routing Using AMQP’s flexible routing model you can route tasks to different workers, or select different message topologies, by configuration or even at runtime return self.users[username] == password except KeyError: return False And you route every request to the same process, then it will keep state between requests. This can also be useful add.get_publisher(connect_timeout=3) Routing options Celery uses the AMQP routing mechanisms to route tasks to different workers. Messages (tasks) are sent to exchanges, a queue binds to an exchange0 码力 | 530 页 | 900.64 KB | 1 年前3
共 363 条
- 1
- 2
- 3
- 4
- 5
- 6
- 37