Skip to content

Static Files

Store files that your application needs at runtime — such as encryption keys, templates, or seed data — in the static directory. These files are included in the build and accessible via settings.static_root_path.

Directory Structure

📁 src
├── 📁 static
│   └── 📄 jwt_private_key
└── 📁 transactions
    └── 📄 create_jwt_token.py

Usage

from amsdal.transactions import transaction
from amsdal.configs.main import settings

@transaction
def CreateJWTToken(data: str) -> str:
    with (settings.static_root_path / 'jwt_private_key').open('rb') as f:
        private_key = f.read()

    token = jwt.encode(
        {'data': data},
        key=private_key,
        algorithm='RS256',
    )

    return token

settings.static_root_path returns a Path pointing to the static directory. You can configure a custom path via the STATIC_MODULE_PATH setting.