【发布时间】:2012-08-02 07:47:41
【问题描述】:
我正在寻找一种方法来为一条路线发送多个响应。 问题是,从我读过的内容来看,我必须返回内容数据。 例如:
@route('/events')
def positions():
for i in xrange(5):
response.content_type = 'text/event-stream'
response.set_header('Cache-Control', 'no-cache')
now = datetime.datetime.now().time().replace(microsecond=0)
return "data: %s\n\n"%now
有没有办法替换某些函数调用中的最后一行,以便我可以发送所有响应然后退出路由?
谢谢,
奥马尔。
【问题讨论】:
-
你不能那样做。一个 HTTP 请求只能有一个 HTTP 响应。