blob: 8515e7b25eb9e60e74700f51d9d2cdfa062dcae1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import time
def main(request, response):
response.headers.set(b'Content-Type', b'text/event-stream')
response.headers.set(b'Cache-Control', b'no-cache')
response.write_status_headers()
while True:
response.writer.write(u"data:msg")
response.writer.write(u"\n")
response.writer.write(u"data: msg")
response.writer.write(u"\n\n")
response.writer.write(u":")
response.writer.write(u"\n")
response.writer.write(u"falsefield:msg")
response.writer.write(u"\n\n")
response.writer.write(u"falsefield:msg")
response.writer.write(u"\n")
response.writer.write(u"Data:data")
response.writer.write(u"\n\n")
response.writer.write(u"data")
response.writer.write(u"\n\n")
response.writer.write(u"data:end")
response.writer.write(u"\n\n")
time.sleep(2)
|