Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

static.py 908B

123456789101112131415161718192021222324252627282930
  1. import re
  2. from urllib.parse import urlsplit
  3. from django.conf import settings
  4. from django.core.exceptions import ImproperlyConfigured
  5. from django.urls import re_path
  6. from django.views.static import serve
  7. def static(prefix, view=serve, **kwargs):
  8. """
  9. Return a URL pattern for serving files in debug mode.
  10. from django.conf import settings
  11. from django.conf.urls.static import static
  12. urlpatterns = [
  13. # ... the rest of your URLconf goes here ...
  14. ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  15. """
  16. if not prefix:
  17. raise ImproperlyConfigured("Empty static prefix not permitted")
  18. elif not settings.DEBUG or urlsplit(prefix).netloc:
  19. # No-op if not in debug mode or a non-local prefix.
  20. return []
  21. return [
  22. re_path(
  23. r"^%s(?P<path>.*)$" % re.escape(prefix.lstrip("/")), view, kwargs=kwargs
  24. ),
  25. ]