Star on GitHub - 5.8k

Flask

Encrypt a .env file in Flask with the Dotenvx SDK, commit it safely, and load its secrets at runtime.

Install

Get the Dotenvx Python SDK.
$ pip install python-dotenvx
And the CLI to encrypt files.
$ curl -sfS https://dotenvx.sh | sh

Encrypt

Encrypt your .env file.

$ dotenvx encrypt

Inject

Then inject your encrypted secrets at runtime.
import os
from flask import Flask
from dotenvx import load_dotenv

load_dotenv()

app = Flask(__name__)

@app.get("/")
def index():
    return f"HELLO: {os.getenv('HELLO')}"