PageRenderTime 29ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/django/contrib/staticfiles/management/commands/runserver.py

https://code.google.com/p/mango-py/
Python | 27 lines | 20 code | 4 blank | 3 comment | 3 complexity | 899a8105e90ba7a7910a871336f11aba MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from optparse import make_option
  2. from django.conf import settings
  3. from django.core.management.commands.runserver import BaseRunserverCommand
  4. from django.contrib.staticfiles.handlers import StaticFilesHandler
  5. class Command(BaseRunserverCommand):
  6. option_list = BaseRunserverCommand.option_list + (
  7. make_option('--nostatic', action="store_false", dest='use_static_handler', default=True,
  8. help='Tells Django to NOT automatically serve static files at STATIC_URL.'),
  9. make_option('--insecure', action="store_true", dest='insecure_serving', default=False,
  10. help='Allows serving static files even if DEBUG is False.'),
  11. )
  12. help = "Starts a lightweight Web server for development and also serves static files."
  13. def get_handler(self, *args, **options):
  14. """
  15. Returns the static files serving handler.
  16. """
  17. handler = super(Command, self).get_handler(*args, **options)
  18. use_static_handler = options.get('use_static_handler', True)
  19. insecure_serving = options.get('insecure_serving', False)
  20. if (settings.DEBUG and use_static_handler or
  21. (use_static_handler and insecure_serving)):
  22. handler = StaticFilesHandler(handler)
  23. return handler