Open
Description
pipenv
reads the .env
files automatically, loading the environment variables that we put into them.
It is a very powerful way to correctly configure an application, following the indications of "The Twelve-Factor App".
An example of a settings.py file converted to an .env
file could be the following:
desarrollo@desarrollo:~/Proyectos/pipenv/blask$ cat .env
# Minimal conf for Blask
FLASK_APP=main.py
# Name of the Template Folder.
templateDir="templates"
# Name of the post Folder
postDir="posts"
# default name of the template file.
defaultLayout="template.html"
# Default name of the static Folder
staticDir="static"
# Title of the blog
tittle="Blask | A Simple Blog Engine Based on Flask"
All the environment variables that we want to define, can be included in the .env
file.
.gitignore
excludes the .env
file so that it can not be versioned, so that we can store sensitive data inside it.
A very popular custom is to create a file .env.example
, with sample data, so that other developers find it very easy to generate their own .env
file from the .env.example
file .