fromtornadoimportweb,ioloop
importdatetime
period=5*1000#every5s
classMainHandler(web.RequestHandler):
defget(self):
self.write(‘HelloTornado‘)
deflike_cron():
printdatetime.datetime.now()
defxiaorui():
print‘xiaorui2s‘
deflee():
print‘wansuilee3s‘
if__nam..
分类:
编程语言 时间:
2015-10-25 22:41:46
阅读次数:
207
from?flask?import?send_from_directory
@app.route(‘/uploads/<filename>‘)
def?uploaded_file(filename):
????return?send_from_directory(app.config[‘UPLOAD_FOLDER‘],
??????????????...
分类:
其他好文 时间:
2015-10-23 19:03:29
阅读次数:
225
转自:http://blog.xiaogaozi.org/2012/09/21/understanding-tornado-dot-gen/理解 tornado.genSEP 21ST, 2012Tornado 通过@asynchronousdecorator 来实现异步请求,但使用的时候必须将 ....
分类:
其他好文 时间:
2015-10-22 12:17:09
阅读次数:
149
一个失败的首页导航例子# -*- coding:utf-8 -*-'''Created on 2015年10月19日'''from flask import Flask, render_templateimport osapp = Flask(__name__)#保存展示在首页的文件链接(即所有的例...
分类:
其他好文 时间:
2015-10-21 19:07:03
阅读次数:
262
一、定义 tornado是一个异步非阻塞模型的服务器(tcp/http)、web框架。二、特性1、高并发 原因:其一,网络事件循环部分根据操作系统选择最高效的,如Linux会是epoll; 其二,框架本身是异步的,用add_timeout代替sleep,AsyncHttpClient代替...
分类:
其他好文 时间:
2015-10-21 00:16:20
阅读次数:
257
Tornado对asynchronous http有很好的支持。 所以跟着demo,总结下一个消息墙要怎么做。思路: 首先查了下有两种思路,一种是client pull 一种是server push。这里使用的是server pull,技术就是挺流行的comet技术。comet大概就是说:我客户端发...
分类:
其他好文 时间:
2015-10-14 18:10:21
阅读次数:
193
转自:http://www.qttc.net/201305320.htmltornado默认是转义所有字符,比较安全,但有时候我们的确需要把字符当做html来解析处理,因此我们需要做些处理。示例:main.py 代码:1234567891011121314import tornado.ioloopi...
分类:
其他好文 时间:
2015-10-13 01:31:26
阅读次数:
197
先把可运行代码列出来, 注释和说明后续补充. tornado.ioloop
tornado.concurrent?Future
tornado.httpclient?AsyncHTTPClient
async_fetch_future(url):
http_client?=?AsyncHTTPClient()
my_future?=?F...
分类:
其他好文 时间:
2015-10-10 12:53:04
阅读次数:
353
今天flask进入模板部分,觉得自己荒废了好多时间,flask一开始要1 安装“虚拟环境”,2 安装flask,3 写视图函数,导入flask-bootsrap模板因为看了两个教程,一个是将view,__init__.py,hello.py 分开的,一个是将它们合并的,最后瞎了,把两个混起了,模板文...
分类:
Web程序 时间:
2015-10-10 00:10:14
阅读次数:
777
1、前期准备通过 pip 或 easy_install 安装了 pymongo 之后, 就能通过 Python 调教 mongodb 了.接着安装个 flask 用来当 web 服务器.当然 mongo 也是得安装的. 对于 Ubuntu 用户, 特别是使用 Server 12.04 的同学, 安装...
分类:
数据库 时间:
2015-10-09 00:26:18
阅读次数:
408