diff --git a/nummi.nginx b/nummi.nginx index f69fd24..28147a4 100644 --- a/nummi.nginx +++ b/nummi.nginx @@ -12,4 +12,9 @@ server { location /static { alias /srv/nummi; } + + location /media { + internal; + alias /var/lib/nummi; + } } diff --git a/nummi/nummi/settings.py b/nummi/nummi/settings.py index fb7478a..0536cfa 100644 --- a/nummi/nummi/settings.py +++ b/nummi/nummi/settings.py @@ -16,7 +16,7 @@ import os # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent MEDIA_ROOT = Path(os.environ.get("NUMMI_MEDIA_ROOT", "/var/lib/nummi")) -MEDIA_URL = "files/" +MEDIA_URL = "media/" # Quick-start development settings - unsuitable for production diff --git a/nummi/nummi/urls.py b/nummi/nummi/urls.py index e201c47..21c2231 100644 --- a/nummi/nummi/urls.py +++ b/nummi/nummi/urls.py @@ -20,7 +20,11 @@ from django.views.generic.base import RedirectView from django.conf import settings from django.conf.urls.static import static -urlpatterns = i18n_patterns( +from . import views + +urlpatterns = [ + path("media/", views.media, name="media"), +] + i18n_patterns( path("", include("main.urls")), path("plot/", include("plot.urls")), path("admin/", admin.site.urls), diff --git a/nummi/nummi/views.py b/nummi/nummi/views.py new file mode 100644 index 0000000..1f84722 --- /dev/null +++ b/nummi/nummi/views.py @@ -0,0 +1,9 @@ +from django.http import HttpResponse +from django.contrib.auth.decorators import login_required + +@login_required +def media(request): + _res = HttpResponse() + _res["Content-Type"] = "" + _res["X-Accel-Redirect"] = request.path + return _res