Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:42:55+00:00 2026-06-11T04:42:55+00:00

I am trying to build a small site with the server push functionality on

  • 0

I am trying to build a small site with the server push functionality on Flask micro-web framework, but I did not know if there is a framework to work with directly.

I used Juggernaut, but it seems to be not working with redis-py in current version, and Juggernaut has been deprecated recently.

Does anyone has a suggestion with my case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:42:57+00:00Added an answer on June 11, 2026 at 4:42 am

    Have a look at Server-Sent Events. Server-Sent Events is a
    browser API that lets you keep open a socket to your server, subscribing to a
    stream of updates. For more Information read Alex MacCaw (Author of
    Juggernaut) post on why he kills juggernaut and why the simpler
    Server-Sent Events are in manny cases the better tool for the job than
    Websockets.

    The protocol is really easy. Just add the mimetype text/event-stream to your
    response. The browser will keep the connection open and listen for updates. An Event
    sent from the server is a line of text starting with data: and a following newline.

    data: this is a simple message
    <blank line>
    

    If you want to exchange structured data, just dump your data as json and send the json over the wire.

    An advantage is that you can use SSE in Flask without the need for an extra
    Server. There is a simple chat application example on github which
    uses redis as a pub/sub backend.

    def event_stream():
        pubsub = red.pubsub()
        pubsub.subscribe('chat')
        for message in pubsub.listen():
            print message
            yield 'data: %s\n\n' % message['data']
    
    
    @app.route('/post', methods=['POST'])
    def post():
        message = flask.request.form['message']
        user = flask.session.get('user', 'anonymous')
        now = datetime.datetime.now().replace(microsecond=0).time()
        red.publish('chat', u'[%s] %s: %s' % (now.isoformat(), user, message))
    
    
    @app.route('/stream')
    def stream():
        return flask.Response(event_stream(),
                              mimetype="text/event-stream")
    

    You do not need to use gunicron to run the
    example app. Just make sure to use threading when running the app, because
    otherwise the SSE connection will block your development server:

    if __name__ == '__main__':
        app.debug = True
        app.run(threaded=True)
    

    On the client side you just need a Javascript handler function which will be called when a new
    message is pushed from the server.

    var source = new EventSource('/stream');
    source.onmessage = function (event) {
         alert(event.data);
    };
    

    Server-Sent Events are supported by recent Firefox, Chrome and Safari browsers.
    Internet Explorer does not yet support Server-Sent Events, but is expected to support them in
    Version 10. There are two recommended Polyfills to support older browsers

    • EventSource.js
    • jquery.eventsource
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a small web application. The application is to store
I'm trying to build small web-system (url shortcutting) using nonsql Cassandra DB, the problem
I am trying build small webcam chat (web application). I searched on google and
I have a small site I built using the Play framework that I'm trying
I am trying to build a small applet that provides some 3d functionality into
I'm trying to build a really simple php controller page for a small site.
I am trying to build a small application that logins into a server and
I'm trying to build a small wiki, but I'm having problems writing the regex
I'm trying to build a small program that hosts vst effects and I would
I'm trying to build a small language with similar syntax and grammatical structure to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.