嗯嗯嗯,这是非常现实的需求,增补到维基中吧
> #!/usr/bin/python2.6
> #-*- coding: utf-8 -*-
>
> # epoll 不支持本地磁盘文件 patch 成 poll
> from eurasia.pyev import *
> mainloop = default_loop(EVBACKEND_POLL).loop
>
> import os, sys
> from eurasia import core
> from traceback import print_exc
> from eurasia.web import httpserver
>
> # 打开调试输出
> core.excepthook = lambda: print_exc(file=sys.stderr)
>
> def handler(httpfile):
> httpfile.start_response('200 OK')
>
> # 文件读取
> fileno = os.open('test.txt', os.O_RDONLY|os.O_NONBLOCK)
> f = core.file(fileno)
> s = f.read()
> os.close(fileno) # or f.close()
>
> httpfile.sendall(s)
> httpfile.close()
>
> httpd = httpserver(':8080', handler)
> httpd.start()
> mainloop()
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“eurasia-users”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 eurasi...@googlegroups.com。
> 要取消订阅此网上论坛,请发送电子邮件至 eurasia-user...@googlegroups.com。
> 若有更多问题,请通过 http://groups.google.com/group/eurasia-users?hl=zh-CN 访问此网上论坛。
>
>
--
人生苦短, Pythonic!
俺: http://about.me/zoom.quiet
开: http://code.ijinshan.com/
豆: http://www.douban.com/group/zoomquiet
书: http://code.google.com/p/openbookproject
蟒: http://code.google.com/p/kcpycamp/wiki/PythoniCamp
On 12月31日, 上午4时25分, "Zoom.Quiet" <zoom.qu...@gmail.com> wrote:
> 2010/12/31 沈崴 <wilei...@gmail.com>: