redis susi linux,第一天 - 初识tornado

---环境准备

lsb_release -a --查看系统版本

ubuntu 12.04

python 2.7.3

---安装

首先安装pip

sudo apt-get install pip

sudo pip install tornado

此时下载的tornado版本为4.2.1

---第一个程序

#coding=utf-8

import tornado.ioloop

import tornado.web

class MainHandler(tornado.web.RequestHandler):

def get(self):

self.write("hello,world")

application = tornado.web.Application([

(r"/",MainHandler),

])

if __name__ == "__main__":

application.listen(8888)

tornado.ioloop.IOLoop.instance().start()

运行程序 python.py

此时去浏览器中,键入地址 http://127.0.0.1:8888/ , 就会看到页面返回 hello,world ,说明程序启动成功。

此时shell中会弹出警告:

WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 0.41ms

这个问题待解决