tornado设置settings
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的更多相关文章
- Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt)
Django 1.6 最佳实践: 如何设置django项目的设置(settings.py)和部署文件(requirements.txt) 作者: Desmond Chen,发布日期: 2014-05- ...
- tornado设置cookie过期时间(expires time)
具体的tornado设置过期时间的东西, 我也是查资料才发现的, 现在就贴代码吧 用户登录之后, 设置cookie, 我使用set_secure_cookie的, 它默认是有个30天的过期时间, 导致 ...
- VSCode 云同步扩展设置 Settings Sync 插件
VSCode 云同步扩展设置 Settings Sync 插件 Hi.大家好,今天又是美好的一天. 关于 Settings Sync扩展: Settings Sync可以同步你当前的VSCode配置环 ...
- C#中使用设置(Settings.settings) Properties.Settings.Default .(配置文件相当重要)
C#中使用设置(Settings.settings) Properties.Settings.Default . 2016年08月04日 15:02:43 zxd9790902 阅读数:10664更多 ...
- iOS开发之iOS程序偏好设置(Settings Bundle)的使用
目录[-] 1.添加设置项 2.设置的控件 3.编辑设置项的文件 4.在程序中获取Settings 和写入Settings 添加UI 5.实现读取设置和保存代码 在Android手机上, 在某个程序里 ...
- tornado设置cookie并加密
最近看看tornado,遇到了sso的东西,了解下如何设置cookie 1.基本cookie set_cookie 方法在用户的浏览中设置 cookie: get_cookie 方法在用户的浏览中获取 ...
- 【读书笔记】iOS-iOS开发之iOS程序偏好设置(Settings Bundle)的使用
在Android手机上, 在某个程序里,通过按Menu键,一般都会打开这个程序的设置,而在iOS里,系统提供了一个很好的保存程序设置的机制.就是使用Settings Bundle. 在按了HOME键的 ...
- webstorm的个性化设置settings
如何更改主题(字体&配色):File -> settings -> Editor -> colors&fonts -> scheme name.主题下载地址 如 ...
- jenkins maven设置settings.xml
环境:jenkins.2.89.3 1.安装settings.xml管理插件Config File Provider Plugin 系统管理->管理插件->搜索Config File P ...
随机推荐
- java实现读取ftp服务器上的csv文件
定义ftp操作接口 import java.io.InputStream; import java.util.List; import org.apache.commons.net.ftp.FTPCl ...
- oracle安装后tnsnames.ora内容
# tnsnames.ora Network Configuration File: D:\Develop\oracle11g\product\11.2.0\dbhome_1\network\admi ...
- 获取当前日期 java
SimpleDateFormat smpDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFo ...
- unknown log format "main" in /nginx/conf/nginx.conf
vi /nginx/conf/nginx.conf找到http{ }模块中的 log_format去掉注释,或是log_format写到了别处. 解决方法: 将log_format 写到http开头 ...
- YAML中重复的KEY的判断
package com.test.util; import java.io.BufferedReader; import java.io.FileInputStream; import java.io ...
- java 图片与文字生成PDF
1.jar包:iText-2.1.5.jar 2.code: import java.awt.Color; import java.io.File; import java.io.FileNotFou ...
- C++的std::string的“读时也拷贝”技术!
C++的std::string的读时也拷贝技术! 嘿嘿,你没有看错,我也没有写错,是读时也拷贝技术.什么?我的错,你之前听说写过时才拷贝,嗯,不错的确有这门技术,英文是Copy On Write,简写 ...
- rsync同步时出现rsync: failed to set times on “xxxx”: Operation not permitted
今天在同步数据的时候提示rsync: failed to set times on “xxxx”: Operation not permitted,一般来说要不是服务器时间不对或者权限没有设置好,下面 ...
- php分享十九:网络带宽预估
网络带宽是指在一个固定的时间内(1秒),能通过的最大位数据.就好象高速公路的车道一样,带宽越大,好比车道越多. 数字信息流的基本单位是bit(比特),时间的基本单位是s(秒),因此bit/s(比特/秒 ...
- MySql(十九):基础——自定义存储过程和函数
MYSQL中创建存储过程和函数分别使用CREATE PROCEDURE和CREATE FUNCTION 使用CALL语句来调用存储过程,存储过程也可以调用其他存储过程 函数可以从语句外调用,能返回标量 ...