Skip to content

Commit

Permalink
Serve media files in non-Debug mode (only used by admin)
Browse files Browse the repository at this point in the history
  • Loading branch information
txels committed Apr 11, 2024
1 parent f6683a4 commit 4afc2d6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 127 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ k8s-restart:
serve:
gunicorn \
--bind 0.0.0.0:8000 \
--workers 2 shipanaro.wsgi \
--workers 2 shipanaro.mediawsgi \
--capture-output --log-file="-" \
--access-logfile="-" | tee -a tripulacio.log

Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ psycopg2-binary = "==2.8.6"
pytz = "==2020.1"
setuptools = "~=69.2"
pip = "~=24.0"
static3 = "*"

[dev-packages]
wheel = "*"
Expand Down
137 changes: 11 additions & 126 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions shipanaro/mediawsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from static import Cling
import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "shipanaro.settings")

media = Cling(".")
django = get_wsgi_application()


def application(environ, start_fn):
if environ["PATH_INFO"].startswith("/media/"):
return media(environ, start_fn)
else:
return django(environ, start_fn)

0 comments on commit 4afc2d6

Please sign in to comment.