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!
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.
Just remember that your Flask application object is the actual WSGI application.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With