Static Files

You can store static files and use them inside your application by using the static directory. The static directory is a special directory that is used to store static files, and they will be copied to a final build.

To use a static file in your application, settings.static_root_path:

- 📁 src
  - 📁 static
    - 📄 jwt_private_key
  - 📁 transactions
    - 📄 create_jwt_token.py
from amsdal_data.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