Setting and retrieving environmental variables in flask applications

python-dotenv actually has nothing to do with Flask. It is for your .env file to be translated into actual env variables. So if you're going to have actual env variables without it, your os.getenv should still work.

Sidenote: You can also use os.environ:

os.environ.get("SECRET")

Set your environment variable in the interpreter:

export SECRET_KEY=123

Call the variable with environ.get():

from os import environ
from flask import Flask

app = Flask(__name__)

app.config['SECRET_KEY'] = environ.get('SECRET_KEY')