runserver with extra development tools:
- interactive debugger that pops up automatically if an exception occurs, courtesy of Werkzeug
- logging of print statements directly into HTML (div float), courtesy of Paste.
Credits: piranha.org.ua
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #!/usr/bin/env python
"""Requires Paste and Werkzeug, use pip/easy_install to install::
$ pip Paste
$ pip Werkzeug
"""
import os
import sys
from werkzeug import run_simple, DebuggedApplication
from django.views import debug
from django.core.handlers.wsgi import WSGIHandler
def null_technical_500_response(request, exc_type, exc_value, tb):
raise exc_type, exc_value, tb
debug.technical_500_response = null_technical_500_response
os.environ['DJANGO_SETTINGS_MODULE'] = 'YOURPROJ.settings'
from paste.debug.prints import PrintDebugMiddleware
app = WSGIHandler()
app = PrintDebugMiddleware(app)
app = DebuggedApplication(app, True)
if __name__ == '__main__':
try:
port = int(sys.argv[1])
except (ValueError, IndexError):
port = 8000
run_simple('0.0.0.0', port, app, True)
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 10 months, 1 week ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months, 2 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 5 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 6 months ago
- Help text hyperlinks by sa2812 1 year, 6 months ago
Comments
Please login first before commenting.