3 ms·
If you have something built in Flask that you want to run on your own VPS rather than Heroku or another IaaS, it's incredibly easy using gunicorn or uwsgi with
by mcescalante 10y ago
If you have something built in Flask that you want to run on your own VPS rather than Heroku or another IaaS, it's incredibly easy using gunicorn or uwsgi with nginx. gunicorn is a bit faster and easier to get started with out of the two.
Here's super rough instructions in a gist, and you can find plenty of great guides on Google of course: https://gist.github.com/mcescalante/5db616b9a826605f1df35f79b09cf6f6 https://gist.github.com/mcescalante/5db616b9a826605f1df35f79...
- TTPrograms 10y agoI've been using nginx for reverse proxying mostly, but what's the purpose of using something like gunicorn or uwsgi over using just bare Flask? I'm not very familiar with best practices in the area. Is the goal to filter requests for performance or something else?
- mcescalante 10y agoThe server config in the gist is definitely just a proxy, forwarding all of the requests through to gunicorn. Many people add more to the configuration block, to do something like serve static assets with nginx rather than their Flask application. From the top paragraph of http://flask.pocoo.org/docs/0.11/deploying/ http://flask.pocoo.org/docs/0.11/deploying/: "While lightweight and easy to use, Flask’s built-in server is not suitable for production as it doesn’t scale well and by default serves only one request at a time. Some of the options available for properly running Flask in production are documented here." In short, the Flask server is not really written or tuned for production, so we use gunicorn or wsgi which are WSGI containers that are production ready :)