Skip to main content

Serve SPA (Single Page Application) in django using whitenoise

Project description

whitenoise-spa

Serve SPA (Single Page Application) in django using whitenoise

Installation

You can install the package via pip:

pip install whitenoise-spa

Usage

  1. Edit your settings.py file and add whitenoise_spa.middleware.WhiteNoiseSPAMiddleware to the MIDDLEWARE list. The middleware should be placed directly after the Django SecurityMiddleware (if you are using it) and before all other middleware. This middleware replaces the whitenoise middleware.
    MIDDLEWARE = [
        # ...
        "django.middleware.security.SecurityMiddleware",
        "whitenoise_spa.middleware.WhiteNoiseSPAMiddleware",
        # ...
    ]
    
  2. Configure SPA root and urls.
    WHITENOISE_SPA_ROOT = BASE_DIR / "dist"
    WHITENOISE_SPA_URLS = ["/", "/login/", "/settings/"]
    

Limitations

  • Does not support wildcard urls for SPA urls.

License

This project is licensed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

whitenoise_spa-1.0.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

whitenoise_spa-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file whitenoise_spa-1.0.0.tar.gz.

File metadata

  • Download URL: whitenoise_spa-1.0.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for whitenoise_spa-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6f2705c77c27cadee8f11f95c9f08cf6b49fa2ddc9e14a60154a6d72b49830c4
MD5 9ab1e12041b6027559659769c66a33f7
BLAKE2b-256 3780b0e36c9cf51e7524f8196fadf4a90feffd7b98666614ab9c3188a1e1093d

See more details on using hashes here.

File details

Details for the file whitenoise_spa-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for whitenoise_spa-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c32248313fae049ad0b3d8a9d043da9ee3d9fcced24f3e8507daef866b9d5346
MD5 f0adace1b052ffcac50c508f8a5565f7
BLAKE2b-256 07c0a8305d6040f0cb05a38818f29f9ce4a6487d2edaab24ea4a22ff2fb03bcf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page