Local Development

Local Development: Python

Run Django, FastAPI, Flask and Python scripts locally with secrets from Ennote instead of a .env file, using ennote secret get with python, uv, Poetry or a Makefile.

Put ennote secret get "<secret>" -- in front of the command that starts your app. Python reads the values with os.environ, like any environment variable.

The examples use a secret named api-env. Set your organization and workspace once with ennote config set, or add --organization-id and --workspace-id flags as in the overview.

Reading Values

settings.py
import os

DATABASE_URL = os.environ["DATABASE_URL"]       # required: fails fast if missing
DEBUG = os.environ.get("DEBUG", "false") == "true"  # optional, with a default

All values arrive as strings. Convert numbers and booleans yourself, or use a settings library such as Pydantic Settings, which reads environment variables and validates types:

config.py
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    database_url: str
    stripe_secret_key: str
    debug: bool = False

settings = Settings()  # reads DATABASE_URL, STRIPE_SECRET_KEY, DEBUG

Django

ennote secret get "api-env" -- python manage.py runserver

Migrations and other management commands need the same variables:

ennote secret get "api-env" -- python manage.py migrate

FastAPI

ennote secret get "api-env" -- uvicorn main:app --reload

Or with the FastAPI CLI: ennote secret get "api-env" -- fastapi dev main.py.

Flask

ennote secret get "api-env" -- flask --app app run --debug

Scripts and Notebooks

ennote secret get "api-env" -- python scripts/sync_customers.py
ennote secret get "api-env" -- jupyter lab

Every notebook kernel started from that Jupyter server sees the variables.

uv and Poetry

Put Ennote first, then the tool that runs your code:

ennote secret get "api-env" -- uv run uvicorn main:app --reload
ennote secret get "api-env" -- poetry run python manage.py runserver

Saving the Command in a Makefile

Python has no package.json scripts, so a Makefile is a common place to share the command with your team:

Makefile
ENNOTE = ennote secret get "api-env" --organization-id "my-org-id" --workspace-id "local-development" --

dev:
    $(ENNOTE) uvicorn main:app --reload

migrate:
    $(ENNOTE) alembic upgrade head

Run make dev or make migrate.

Keeping python-dotenv

If your code calls load_dotenv(), you can leave it in place. By default it does not override variables that are already set, so the values from Ennote win, and it does nothing when no .env file exists.

Need Help?

If you encounter any issues or have questions, don't hesitate to contact support. Our team is here to assist you with any challenges you might face.