production
or locally
for example. This is where you also store more sensible information like SECRET_KEY
or API credentials. Storing those directly in your web app code can be easy at first, but it is not safe when you will push your code in production, so taking good habits from the beginning is a good idea.app.py
in your folder :index.html
so create that file too inside a templates
folder and paste this code inside :flask run
. As you can see we are greeted like expected, with all the ‘!!!!’, but I had to export the variable in my terminal. Every time you close your terminal you need to do that again. Not very efficient.Procfile
at the root of your folder. Paste this code inside :requirements.txt
file :EXCITED
variable to true. You can do that on the web interface of Heroku, or using the CLI with :Hello !!!!
.env
and .flaskenv
files. By convention, the .flaskenv
is where you store your variables related to your flask configuration, such as the type of environment, or the files that contains your flask app. For this example we will write those lines inside this file :.env
file contains the sensible variable information that your app needs to run. This file stay locally and you must include it in your .gitignore
to avoid sharing sensible informations. For the purpose of this tutorial we will just include one variable :heroku local web
then you don’t need to install python-dotenv
, Heroku will detect the .env
file by itself..env
files on the config of your Heroku app (with the web interface or the CLI).