1 | import django
|
---|
2 | import sys
|
---|
3 | from django.core.servers.basehttp import ServerHandler
|
---|
4 |
|
---|
5 | __all__ = ["CGI_Server_Handler"]
|
---|
6 |
|
---|
7 | __version__ = "0.1".strip ()
|
---|
8 | sys_version = sys.version.split () [0]
|
---|
9 | software_version = "CGI_Wrapper/%s Python/%s" % (__version__, sys_version)
|
---|
10 |
|
---|
11 | class CGI_Server_Handler (ServerHandler) :
|
---|
12 | """A simpuated CGI server"""
|
---|
13 |
|
---|
14 | origin_server = False
|
---|
15 | default_settings_module = "settings"
|
---|
16 | server_software = software_version
|
---|
17 | status = "500"
|
---|
18 |
|
---|
19 | def __init__ (self, environ, * path) :
|
---|
20 | sys.path.extend (path)
|
---|
21 | key = "DJANGO_SETTINGS_MODULE"
|
---|
22 | if key not in environ :
|
---|
23 | environ [key] = self.default_settings_module
|
---|
24 | self.request_handler = self
|
---|
25 | super (CGI_Server_Handler, self).__init__ \
|
---|
26 | ( sys.stdin, sys.stdout, sys.stderr, environ
|
---|
27 | , multithread = False
|
---|
28 | , multiprocess = False
|
---|
29 | )
|
---|
30 | # end def __init__
|
---|
31 |
|
---|
32 | def run (self, cls) :
|
---|
33 | super (CGI_Server_Handler, self).run (cls ())
|
---|
34 | # end def run
|
---|
35 |
|
---|
36 | def log_request (self, status, bytes) :
|
---|
37 | pass ### for now, ignore it
|
---|
38 | # end def log_request
|
---|
39 |
|
---|
40 | # end class CGI_Server_Handler
|
---|