Reputation: 85
I'm working on a flask app: https://github.com/josephmalisov/todo_list When I run it on computer, I am told (with the warning in red):
Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
First of all, isn't that contradictory?
But mainly, I want to know the difference between a development server and production deployment. When I run it on heroku, it works, so what's the benefit of doing this lengthy flask tutorial of Deploy to Production?
Upvotes: 2
Views: 3131
Reputation: 192
To answer your 'main question', as the Flask documentation outlines:
Flask’s built-in server is not suitable for production as it doesn’t scale well.
This will not be apparent to you on Heroku if you're the only person using the application, but as more and more users visit your app, the Flask server will not handle this well (it is not designed to, versus something like Gunicorn).
The 'environment' string to which you are referring is actually a configuration setting that allows you to tell the application how to behave. For example, by setting the environment to 'development' (i.e. export FLASK_ENV=development
), you will get certain behaviours from the application and any extensions that you would not want in production, e.g. interactive debug when an error is thrown. If it is set to 'production', you will not get these behaviours.
There is no real contradiction here: the app isn't configured to run locally as 'development', which is unrelated to the use of the flask development server.
The flask documentation is superb, so I would recommend you look there to understand how flask works. Also take a look at Miguel Grinberg's excellent Flask Mega Tutorial series.
Upvotes: 4