twisted08 分发动态处理的http服务器
来源:互联网 发布:免费b2b群发软件 编辑:程序博客网 时间:2024/06/10 06:35
from twisted.internet import reactorfrom twisted.web.server import Sitefrom twisted.web.resource import Resource, NoResourcefrom twisted.web.static import Filefrom calendar import calendarclass Calendar(Resource):def __init__(self, year):assert(isinstance(year, (int, long)))self.year = yeardef render_GET(self, request):return '<html><h1><pre>%s</pre></h1></html>' % calendar(self.year)class URL_Dispatcher(Resource):def getChild(self, name, request):if name == '/' or not name:return self#return ico resouceelif name == 'favicon.ico':return File('d:/down.png')#Only process http://localhost:8000/1995#Can't process http://localhost:8000/1995/1995 or http://localhost:8000/1995/1995/../../..#if return a resource object (derived from Resource)#will continue accesss by level (sperator by '/')#until no '/'elif name.isdigit() and int(name) > 1990:print 'name->:',namey = int(name)return Calendar(y)else:return NoResource()def render_GET(self, request):return '<html><h1>Calendar</h1></html>'if __name__ == '__main__':s = Site(URL_Dispatcher())reactor.listenTCP(8000,s)reactor.run()
0 0
- twisted08 分发动态处理的http服务器
- 事件的分发处理
- HTTP 服务器的100 Continue处理规范
- http服务器--session处理
- 消息的分发与处理
- twisted07 动态页http服务器
- Tomcat服务器t处理HTTP请求的过程
- 收到服务器401响应的处理(HTTP或SIP)
- Tomcat服务器处理一个http请求的过程
- mongoose http服务器对TCP流的接收处理
- 服务器如何处理http请求
- 手写服务器httpserver_封装分发器和多请求处理
- 嵌套协议的消息分发处理
- android触摸事件的分发和处理
- View与ViewGroup的分发处理逻辑
- Android触摸事件的分发处理
- 操作系统的 输入-分发-处理-输出
- Android触摸事件的分发、拦截、处理
- 了解ASP.NET MVC几种ActionResult的本质:JavaScriptResult & JsonResult
- 数据结构上机测试2-2:单链表操作B
- 转:oracle数据库里dual表是什么表?
- hadoop学习笔记2
- 常用的正则表达式集锦
- twisted08 分发动态处理的http服务器
- 关联分析(从基础到高级)
- Leetcode 188 Best Time to Buy and Sell Stock IV 至多k次买卖股票最大收益
- Leetcode#21||Merge Two Sorted Lists
- 正则表达式中的分组断言
- HDU 3367 Pseudoforest (克鲁斯卡尔_最大生成树:带一环)
- Java多线程系列--“JUC锁”07之 LockSupport
- HDFS的体系架构
- linux 内核移植和根文件系统的制作