|
|
@ -4,7 +4,6 @@ Basic web server / framework. |
|
|
|
|
|
|
|
|
|
|
|
from SocketServer import ThreadingMixIn |
|
|
|
from SocketServer import ThreadingMixIn |
|
|
|
import BaseHTTPServer |
|
|
|
import BaseHTTPServer |
|
|
|
from BaseHTTPServer import BaseHTTPRequestHandler |
|
|
|
|
|
|
|
import urlparse |
|
|
|
import urlparse |
|
|
|
import cgi |
|
|
|
import cgi |
|
|
|
|
|
|
|
|
|
|
@ -30,25 +29,25 @@ class ThreadedHTTPServer(ThreadingMixIn, BaseHTTPServer.HTTPServer): |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestHandler(BaseHTTPRequestHandler): |
|
|
|
class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
|
|
|
""" |
|
|
|
""" |
|
|
|
Basic web server request handler. Handles GET and POST requests. You should |
|
|
|
Basic web server request handler. Handles GET and POST requests. You should |
|
|
|
inherit from this class and implement h_ methods for handling requests. |
|
|
|
inherit from this class and implement h_ methods for handling requests. |
|
|
|
If no path is set, it dispatches to the 'index' or 'default' method. |
|
|
|
If no path is set, it dispatches to the 'index' or 'default' method. |
|
|
|
""" |
|
|
|
""" |
|
|
|
def log_message(self, fmt, *args): |
|
|
|
def log_message(self, fmt, *args): # pylint: disable=arguments-differ |
|
|
|
"""Overrides BaseHTTPRequestHandler which logs to the console. We log |
|
|
|
"""Overrides BaseHTTPRequestHandler which logs to the console. We log |
|
|
|
to our log file instead""" |
|
|
|
to our log file instead""" |
|
|
|
fmt = "{0} {1}" |
|
|
|
fmt = "{0} {1}" |
|
|
|
self.scriptform.log.info(fmt.format(self.address_string(), args)) |
|
|
|
self.scriptform.log.info(fmt.format(self.address_string(), args)) |
|
|
|
|
|
|
|
|
|
|
|
def do_GET(self): |
|
|
|
def do_GET(self): # pylint: disable=invalid-name |
|
|
|
""" |
|
|
|
""" |
|
|
|
Handle a GET request. |
|
|
|
Handle a GET request. |
|
|
|
""" |
|
|
|
""" |
|
|
|
self._call(*self._parse(self.path.lstrip('/'))) |
|
|
|
self._call(*self._parse(self.path.lstrip('/'))) |
|
|
|
|
|
|
|
|
|
|
|
def do_POST(self): |
|
|
|
def do_POST(self): # pylint: disable=invalid-name |
|
|
|
""" |
|
|
|
""" |
|
|
|
Handle a POST request. |
|
|
|
Handle a POST request. |
|
|
|
""" |
|
|
|
""" |
|
|
|