Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server-Sent Events with Nginx and uWSGI

Is it possible to use server-sent events from a python/Flask application that is behind uWSGI and Nginx?

I've found packages that implement SSE in python/Flask, but they seem to all do so using gevent and greenlets.

https://github.com/DazWorrall/flask-sse

Thanks!

like image 740
Ethan Avatar asked Mar 11 '13 18:03

Ethan


People also ask

Is Nginx required for uWSGI?

Can I then ditch NGINX? uWSGI could be used as a standalone web server in production, but that is not it's intentional use. It may sound odd, but uWSGI was always supposed to be a go-between a full-featured web server like NGINX and your Python files.

Is flask a uWSGI?

Just remember that your Flask application object is the actual WSGI application.

What is the use of uWSGI?

uwsgi (all lowercase) is the native binary protocol that uWSGI uses to communicate with other servers. uWSGI is often used in conjunction with web servers such as Cherokee and Nginx, which offer direct support for uWSGI's native uwsgi protocol, to serve Python web applications such as Django.

How do you run uWSGI flask?

The most basic way to run uWSGI is to tell it to start an HTTP server and import your application. If you're using the app factory pattern, you'll need to create a small Python file to create the app, then point uWSGI at that.


1 Answers

Recent versions of uWSGI (from 1.9) have built-in support for websockets / SSE. This article provides an excellent guide:

uWSGI docs: Offloading Websockets and Server-Sent Events

like image 137
Freek Wiekmeijer Avatar answered Nov 15 '22 00:11

Freek Wiekmeijer