1.作用

设置应用程序相关参数

2.用法

settings = dict()
settings["debug"] = True
tornado.web.Application.__init__(self, handlers, **settings)

3.相关参数详解

1)debug

设置应用程序为debug模式,debug模式下,修改了.py文件后,application会自动重启。

或者在.py文件中引入自动启动包 import tornado.autoreload

在部署正式时,需将debug=False,可加快执行速度。

2)log_function

自定义日志输出格式

tornado定义了三种日志处理器,access_log,app_log,gen_log

通过定义log_function函数,可以自定义输出格式

def log_func(handler):
if handler.get_status() < 400:
log_method = access_log.info
elif handler.get_status() < 500:
log_method = access_log.warning
else:
log_method = access_log.error
request_time = 1000.0 * handler.request.request_time()
log_method("%d %s %s (%s) %s %s %.2fms",
handler.get_status(), handler.request.method,
handler.request.uri, handler.request.remote_ip,
handler.request.headers["User-Agent"],
handler.request.arguments,
request_time)
settings["log_function"] = log_func

3)static_path

静态文件路径

4)static_url_prefix

静态文件url前缀

5)template_path

模板文件路径

6)gzip

设置gzip压缩

tornado设置settings的更多相关文章

  1. Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt)

    Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt) 作者: Desmond Chen,发布日期: 2014-05- ...

  2. tornado设置cookie过期时间(expires time)

    具体的tornado设置过期时间的东西, 我也是查资料才发现的, 现在就贴代码吧 用户登录之后, 设置cookie, 我使用set_secure_cookie的, 它默认是有个30天的过期时间, 导致 ...

  3. VSCode 云同步扩展设置 Settings Sync 插件

    VSCode 云同步扩展设置 Settings Sync 插件 Hi.大家好,今天又是美好的一天. 关于 Settings Sync扩展: Settings Sync可以同步你当前的VSCode配置环 ...

  4. C#中使用设置(Settings.settings) Properties.Settings.Default .(配置文件相当重要)

    C#中使用设置(Settings.settings) Properties.Settings.Default . 2016年08月04日 15:02:43 zxd9790902 阅读数:10664更多 ...

  5. iOS开发之iOS程序偏好设置(Settings Bundle)的使用

    目录[-] 1.添加设置项 2.设置的控件 3.编辑设置项的文件 4.在程序中获取Settings 和写入Settings 添加UI 5.实现读取设置和保存代码 在Android手机上, 在某个程序里 ...

  6. tornado设置cookie并加密

    最近看看tornado,遇到了sso的东西,了解下如何设置cookie 1.基本cookie set_cookie 方法在用户的浏览中设置 cookie: get_cookie 方法在用户的浏览中获取 ...

  7. 【读书笔记】iOS-iOS开发之iOS程序偏好设置(Settings Bundle)的使用

    在Android手机上, 在某个程序里,通过按Menu键,一般都会打开这个程序的设置,而在iOS里,系统提供了一个很好的保存程序设置的机制.就是使用Settings Bundle. 在按了HOME键的 ...

  8. webstorm的个性化设置settings

    如何更改主题(字体&配色):File -> settings -> Editor -> colors&fonts -> scheme name.主题下载地址 如 ...

  9. jenkins maven设置settings.xml

    环境:jenkins.2.89.3 1.安装settings.xml管理插件Config File Provider Plugin  系统管理->管理插件->搜索Config File P ...

随机推荐

  1. HDU - 4198 Quick out of the Harbour (BFS+优先队列)

    Description Captain Clearbeard decided to go to the harbour for a few days so his crew could inspect ...

  2. 实战VMware的三种网络模式

    来源于:http://www.aneasystone.com/archives/2015/04/three-network-modes-of-vmware-in-action.html 一.实验目的 ...

  3. 输出控制台信息到日志 并 通过cronolog对tomcat进行日志切分

    windows下tomcat默认并不会把控制台输出的信息都记录进日志文件.但是在生产环境中,出现问题时,控制台的日志输出是无法查据的,因此需要将日志记录下来. 解决方法: 输出日志到文件 修改tomc ...

  4. EntityFramework 5.0 CodeFirst 教程01-搭建环境和快速上手

    ----------------------------目录------------------------------ EntityFramework 5.0 CodeFirst 教程03-数据结构 ...

  5. Nginx 日志改成 JSON 格式

    Nginx 日志默认为普通文本的格式,例如,下面是 Nginx 的一行访问日志: 10.88.122.105 - - [02/Dec/2017:09:15:04 +0800] "GET /j ...

  6. centos7 修改中文字符集 How to avoid having to `export LC_ALL=“zh_CN.UTF-8”` upon each SSH connection

    Each time I SSH to my Fedora Server, the locale setting is not right. $ locale locale: Cannot set LC ...

  7. 客户端调用rcf库 时,返回值千万不要用auto

    std::vector<std::wstring> list = Client.xxxx(); 千万不要写成 auto  list = Client.xxxx();

  8. ThinkPHP+jQuery EasyUI Datagrid查询数据的简单处理

    ThinkPHP和jQuery EasyUI这两个都是不错的框架,现在要把它两个整合到一块,做个简单的Ajax调用查询. 在ThinkPHP模板中引入EasyUI的相关文件,然后设置按钮3的调用: & ...

  9. android开发学习---linux下开发环境的搭建&& android基础知识介绍

    一.配置所需开发环境 1.基本环境配置 JDK 5或以上版本(仅有JRE不够) (http://www.oracle.com/technetwork/java/javase/downloads/ind ...

  10. 【Android】Android模拟器的安装

    目录结构: contents structure [+] 使用VMware安装Android模拟器 安装安卓(Android)系统前VMware虚拟机的配置 安装安卓(Android)系统 安装安卓( ...