The server module contains various classes pertaining to creating HTTP servers.
The Argument class encapsulates the concept of an HTTP argument passed through a URL request.
Arguments can have a specific type, can be required or optional, and can have a default value if they are optional and not passed in the request.
Convert the given value to the expected type of the Argument.
Return the default value for this Argument.
Determine if this is a required Argument or an optional Argument.
The HttpServerThread class provides an implementation of an HttpServer that runs in its own thread.
Example:
from time import sleep
from pyamp.web.http.requests import StoppableRequestHandler
server = HttpServerThread(12345, StoppableRequestHandler)
server.start()
while True:
try:
sleep(0.1)
except (KeyboardInterrupt, SystemExit):
print "Stopping server!"
server.shutdown()
break
print "Done."
Called once during every cycle of the thread.
Create a basic HTTP server.
Example:
from BaseHTTPServer import BaseHTTPRequestHandler
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
print "GET:", self.path
server = HttpServer(12345, RequestHandler)
server.serve_forever()