Tornado是web框架兼web應用框架。
1.作爲web框架,是一個輕量級的web框架,擁有異步非阻塞IO處理方式。
2.作爲web服務器,有較出色的負載能力。
HTTP服務器
異步編程
WebSockets
一、安裝Tornado
pip install tornado
二、Tornado代碼
文件test01.py,代碼內容:
# coding:utf-8
import tornado.web
import tornado.ioloop
class IndexHandler(tornado.web.RequestHandler):
def get(self):
pass
def post(self):
pass
if __name__ == '__main_':
app = tornado.web.Application([(r"/",IndexHandler)])
app.listen(8000)
tornado.ioloop.IOLoop.current().satrt()
app = tornado.web.Application([(r"/",IndexHandler)]) --應用,路由映射列表,操作執行什麼內容
app.listen(8000) --把應用綁定監聽
tornado.ioloop.IOLoop.current().satrt() --循環監聽
啓動應用: python test01.py
然後 訪問網址 http://localhost:8000