Skip to content

Commit

Permalink
Add whitenoise to serve javascript, reduces js size by ~20%
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-s committed Nov 28, 2020
1 parent c4f6fc6 commit 8994f28
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
24 changes: 9 additions & 15 deletions app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^ar@p4e$sdqoa*=gd)*(e*(+&k3rv#x_*v5w*wb9+ef@097-fd'
SECRET_KEY = os.environ.get('SECRET_KEY', "a-not-so-secret-key")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

DEBUG = os.environ.get('DEBUG', False)
ALLOWED_HOSTS = ['*', ]


# Application definition

INSTALLED_APPS = [
Expand All @@ -48,6 +46,7 @@

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand All @@ -74,9 +73,6 @@
},
]

WSGI_APPLICATION = 'app.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

Expand Down Expand Up @@ -115,9 +111,7 @@
TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


Expand All @@ -126,13 +120,13 @@

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'

CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels.layers.InMemoryChannelLayer"
}
"default": {
# IMPORTANT, do not ever use this in a production environment
"BACKEND": "channels.layers.InMemoryChannelLayer"
}
}


ASGI_APPLICATION = 'sockpuppet.routing.application'

WSGI_APPLICATION = 'app.wsgi.application'
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Django sockpuppet expo

## Running locally

```
pip install -r requirements.in
yarn install
yarn run watch
python manage.py migrate
python manage.py runserver
```


1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ django-sockpuppet
requests
django-pygments-renderer
django-widget-tweaks
whitenoise

# deployment
fabric
Expand Down

1 comment on commit 8994f28

@jonathan-s
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must have been tired when I wrote that commit, I meant that it reduces js size to 20kb...

Please sign in to comment.