WolfgangFahl / pyFlaskBootstrap4

Flask + Bootstrap 4 static components and templates for webprojects
Apache License 2.0
5 stars 2 forks source link

add Server side event support #17

Closed WolfgangFahl closed 2 years ago

WolfgangFahl commented 3 years ago

see

Code snippet:

 def getEvent(self):
        '''this could be any function that blocks until data is ready'''
        time.sleep(1.0)
        s=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
        return s    

    def eventFeed(self):
        return Response(self.genEventStream(), mimetype="text/event-stream")

    def genEventStream(self):
        while True:
            # wait for source data to be available, then push it
            yield 'data: {}\n\n'.format(self.getEvent())
WolfgangFahl commented 3 years ago

see

WolfgangFahl commented 3 years ago
WolfgangFahl commented 3 years ago

http://wiki.bitplan.com/index.php/Server-Sent-Events

WolfgangFahl commented 3 years ago

What pubsub module to use? See

WolfgangFahl commented 2 years ago

see