Skip to content

nationalarchives/ds-forms

Repository files navigation

TNA Python Flask Application

Quickstart

# Build and start the container
docker compose up -d

Add the static assets

During the first time install, your app/static/assets directory will be empty.

As you mount the project directory to the /app volume, the static assets from TNA Frontend installed inside the container will be "overwritten" by your empty directory.

To add back in the static assets, run:

docker compose exec app cp -r /app/node_modules/@nationalarchives/frontend/nationalarchives/assets /app/app/static

Run tests

docker compose exec dev poetry run python -m pytest

Format and lint code

docker compose exec dev format

Environment variables

In addition to the base Docker image variables, this application has support for:

Variable Purpose Default
CONFIG The configuration to use config.Production
DEBUG If true, allow debugging[^1] False
COOKIE_DOMAIN The domain to save cookie preferences against none
CSP_IMG_SRC A comma separated list of CSP rules for img-src 'self'
CSP_SCRIPT_SRC A comma separated list of CSP rules for script-src 'self'
CSP_STYLE_SRC A comma separated list of CSP rules for style-src 'self'
CSP_FONT_SRC A comma separated list of CSP rules for font-src 'self'
CSP_CONNECT_SRC A comma separated list of CSP rules for connect-src 'self'
CSP_MEDIA_SRC A comma separated list of CSP rules for media-src 'self'
CSP_WORKER_SRC A comma separated list of CSP rules for worker-src 'self'
CSP_FRAME_SRC A comma separated list of CSP rules for frame-src 'self'
CSP_FRAME_ANCESTORS A comma separated list of CSP rules for frame-accestors 'self'
CSP_REPORT_URL The URL to report CSP violations to none
FORCE_HTTPS Redirect requests to HTTPS as part of the CSP none
SESSION_REDIS_URL A URL to a Redis instance used by session storage none
RATELIMIT_REDIS_URL A URL to a Redis instance used by rate limiting none
RATELIMIT_DEFAULT The default rate limiting amount[^2] none
ALTCHA_HMAC_KEY A secret key to use when generating ALTCHA challenges none
CACHE_TYPE https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching FileSystemCache
CACHE_DEFAULT_TIMEOUT The number of seconds to cache pages for 3600
CACHE_DIR Directory for cache when using CACHE_TYPE=FileSystemCache /tmp
CACHE_REDIS_URL The connection string for Redis when using CACHE_TYPE=RedisCache none
AWS_ACCESS_KEY_ID The access key ID (used to send emails with SES and store files with S3) none
AWS_SECRET_ACCESS_KEY The secret access key (used to send emails with SES and store files with S3) none
AWS_SESSION_TOKEN The AWS session token (used to send emails with SES and store files with S3) none
AWS_DEFAULT_REGION The default AWS region none
GA4_ID The Google Analytics 4 ID none

[^1] Debugging in Flask [^2] Rate limit notation

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages