Why do I need to use a web server, middleware, etc, for a simple Flask application? [closed] Why do I need to use a web server, middleware, etc, for a simple Flask application? [closed] flask flask

Why do I need to use a web server, middleware, etc, for a simple Flask application? [closed]


The Django docs have this to say about the included dev server:

We’ve included this with Django so you can develop things rapidly, without having to deal with configuring a production server – such as Apache – until you’re ready for production.

Now’s a good time to note: don’t use this server in anything resembling a production environment. It’s intended only for use while developing. (We’re in the business of making Web frameworks, not Web servers.)

The two advantages of Apache/Nginx over the dev server that come to mind immediately:

  • Django dev server isn't designed with security in mind. Apache/Nginx, being designed to be exposed over the network, have had (and continue to have) effort put into finding/fixing vulnerabilities that the Django dev server just hasn't had.
  • A lot of the requests you serve will be static files (images, JS, CSS). Nginx and Apache are going to be far more efficient in serving these assets than a server written in Python.