summaryrefslogtreecommitdiffstats
path: root/module/web/run_server.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-04-02 14:59:12 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-04-02 14:59:12 +0200
commitae8f974c33ae5f4674e7812b339d04135e2e6b9f (patch)
treee664525b544e64b1237f8208de4a385e16770152 /module/web/run_server.py
parentparser fix (diff)
downloadpyload-ae8f974c33ae5f4674e7812b339d04135e2e6b9f.tar.xz
django embedded
Diffstat (limited to 'module/web/run_server.py')
-rwxr-xr-xmodule/web/run_server.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/module/web/run_server.py b/module/web/run_server.py
index 5ffa45781..6aa8bdba4 100755
--- a/module/web/run_server.py
+++ b/module/web/run_server.py
@@ -2,6 +2,9 @@
# -*- coding: utf-8 -*-
import os
import sys
+import django
+from django.core.servers.basehttp import AdminMediaHandler, WSGIServerException, WSGIServer, WSGIRequestHandler
+from django.core.handlers.wsgi import WSGIHandler
os.environ["DJANGO_SETTINGS_MODULE"] = 'settings'
@@ -15,14 +18,10 @@ class Output:
def __getattr__(self, attr):
return getattr(self.stream, attr)
-sys.stderr = Output(sys.stderr)
+#sys.stderr = Output(sys.stderr)
#sys.stdout = Output(sys.stdout)
def handle(* args):
- import django
- from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException
- from django.core.handlers.wsgi import WSGIHandler
-
try:
if len(args) == 1:
try:
@@ -37,7 +36,7 @@ def handle(* args):
addr = '127.0.0.1'
port = '8000'
- print addr, port
+ #print addr, port
admin_media_path = ''
shutdown_message = ''
@@ -46,9 +45,9 @@ def handle(* args):
from django.conf import settings
from django.utils import translation
- print "\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
+ print "Django version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE)
print "Development server is running at http://%s:%s/" % (addr, port)
- print "Quit the server with %s." % quit_command
+ #print "Quit the server with %s." % quit_command
translation.activate(settings.LANGUAGE_CODE)
@@ -74,7 +73,17 @@ def handle(* args):
if shutdown_message:
print shutdown_message
sys.exit(0)
-
+
+class ownRequestHandler(WSGIRequestHandler):
+ def log_message(self, format, *args):
+ return
+
+
+def run(addr, port, wsgi_handler):
+ server_address = (addr, port)
+ httpd = WSGIServer(server_address, ownRequestHandler)
+ httpd.set_app(wsgi_handler)
+ httpd.serve_forever()
if __name__ == "__main__":
handle(*sys.argv[1:])