@@ -0,0 +1,1349 @@
+from gevent import monkey; monkey.patch_all()%0Afrom gevent import sleep%0A%0Afrom bottle import get, post, request, response%0Afrom bottle import GeventServer, run%0A%0A%0Asse_test_page = %22%22%22%0A%3C!DOCTYPE html%3E%0A%3Chtml%3E%0A%09%3Chead%3E%0A%09%09%3Cmeta charset=%22UTF-8%22 /%3E%0A%09%09%3Cscript src=%22http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js %22%3E%3C/script%3E%0A%09%09%3Cscript%3E%0A%09%09%09$(document).ready(function() %7B%0A%09%09%09%09var es = new EventSource(%22stream%22);%0A%09%09%09%09es.onmessage = function (e) %7B%0A%09%09%09%09%09$(%22#log%22).html($(%22#log%22).html()%0A%09%09%09%09%09%09+ %22%3Cp%3EEvent: %22 + e.event + %22, data: %22 + e.data + %22%3C/p%3E%22);%0A%09%09%09%09%7D;%0A%09%09%09%7D)%0A%09%09%3C/script%3E%0A%09%3C/head%3E%0A%09%3Cbody%3E%0A%09%09%3Cdiv id=%22log%22 style=%22font-family: courier; font-size: 0.75em;%22%3E%3C/div%3E%0A%09%3C/body%3E%0A%3C/html%3E%0A%22%22%22%0A%0A%0A@get('/')%0Adef index():%0A%09return sse_test_page%0A%0A%0A@get('/stream')%0Adef stream():%0A%09# %22Using server-sent events%22%0A%09# https://developer.mozilla.org/en-US/docs/Server-sent_events/Using_server-sent_events%0A%09# %22Stream updates with server-sent events%22%0A%09# http://www.html5rocks.com/en/tutorials/eventsource/basics/%0A%0A%09response.content_type  = 'text/event-stream'%0A%09response.cache_control = 'no-cache'%0A%0A%09# Set client-side auto-reconnect timeout, ms.%0A%09yield 'retry: 100%5Cn%5Cn'%0A%0A%09n = 1%0A%0A%09# Keep connection alive no more then... (s)%0A%09end = time.time() + 60%0A%09while time.time() %3C end:%0A%09%09yield 'data: %25i%5Cn%5Cn' %25 n%0A%09%09n += 1%0A%09%09sleep(1)%0A%0A%0Aif __name__ == '__main__':%0A%09run(server=GeventServer)%0A

Add sse example