from eurasia.core import sleep
from eurasia.greenlet import greenlet
from eurasia.web import httpserver, mainloop
from time import time
def handler(httpfile):
httpfile['Content-Type'] = 'text/html'
httpfile.write('<html>hello world!</html>')
httpfile.close()
def loop():
while True:
print('test: %d'%time())
sleep(1.)
greenlet(loop).switch() # 使用 greenlet 启动一个协程
httpd = httpserver(('', 6666), handler)
httpd.start()
mainloop()
这部分内容我会增补到文档中。
写成这样就可以了(要用到 greenlet,默认打包在 eurasia 中):
from eurasia.greenlet import greenlet
from eurasia.core import sleep
from eurasia.web import httpserver, mainloop
from time import timegreenlet(loop).switch() # 使用 greenlet 启动一个协程
def handler(httpfile):
httpfile['Content-Type'] = 'text/html'
httpfile.write('<html>hello world!</html>')
httpfile.close()
def loop():
while True:
print('test: %d'%time())
sleep(1.)
这部分内容我会增补到文档中。
httpd = httpserver(('', 6666), handler)
httpd.start()
mainloop()
--
您收到此邮件是因为您订阅了 Google 网上论坛的"eurasia-users"论坛。
要向此网上论坛发帖,请发送电子邮件至 eurasi...@googlegroups.com。
要取消订阅此网上论坛,请发送电子邮件至 eurasia-user...@googlegroups.com。
若有更多问题,请通过 http://groups.google.com/group/eurasia-users?hl=zh-CN 访问此网上论坛。
working ... :)
短期计划是有的,我现在正在研究,只是抱歉的是很难在短期内完 :(