file :https://github.com/sloria/environs
install
pip install environs
Code example
# -*- coding: utf-8 -*-
from environs import Env
env = Env()
# read .env file, if it exists
env.read_env()
env.str('FLASK_APP') # app.py
env.bool('FLASK_DEBUG') # True
.env file
# .env
FLASK_APP = app.py
FLASK_ENV = development
FLASK_DEBUG = 1
Types of support
env.str
env.bool
env.int
env.float
env.decimal
env.list (accepts optional subcast keyword argument)
env.dict (accepts optional subcast keyword argument)
env.json
env.datetime
env.date
env.timedelta (assumes value is an integer in seconds)
env.url
env.uuid
env.log_level
env.path (casts to a pathlib.Path)