The web module contains classes and methods to perform tasks pertaining to the world wide web, such as accessing the content of a web page.
Contains the Hacking class which provides functions pertaining to hacking web sites.
The web module provides classes, and functions which provide various functionality respective to websites.
The http module contains modules pertaining to creating an HTTP server to serve pages upon request.
The constants module contains classes which define constants relating to HTTP data.
The ContentTypes class contains constants pertaining to different types of content.
A BMP image content.
CSS content.
A GIF image content.
An ICO image content.
JavaScript content.
JSON content.
An PNG image content.
Standard text HTML content.
The HeaderIds class contains constants pertaining to header identifiers.
The content type header id.
The location header id.
The user agent header id.
The Keys class defines constants that are used as keys to access certain dictionary values.
The key for the entry containing the error message.
The OperatingSystems class contains constants pertaining to the strings used to identify various operating systems.
The BeOS OS.
The Linux OS.
The Mac OS.
The OS/2 OS.
The OpenBSD OS.
The QNX OS.
The SearchBot OS.
The Sun OS OS.
The Windows 2000 OS.
The Windows 3.11 OS.
The Windows 7 OS.
The Windows 95 OS.
The Windows 98 OS.
The Windows ME OS.
The Windows NT 4.0 OS.
The Windows Server 2003 OS.
The Windows Vista OS.
The Windows XP OS.
The StatusCodes class contains constants pertaining to HTTP status codes.
The file not found status code.
The found status code.
The internal server error status code.
The moved permanently status code.
The OK status code.
The headers module contains a class which provides the ability to create a specific HTTP header.
The Header class provides the ability to create a specific HTTP header.
Create a content type header.
The page module contains the definition of the BasePage class which provides the base functionality for implementing a page that can be served by an HTTP server.
This module also contains other classes for defining various types of pages.
The BasePage class contains the basic functionality that is shared among all pages.
Check that all the required properties are defined.
The arguments class defines a dictionary mapping names of arguments to actual Argument objects that this Page accepts. These can be required, or optional arguments. This provides the ability to perform error checking on the request to the page to determine if the correct number of arguments was passed in the request.
The contentType property contains the type of content contained in this Page.
The errorCodes property defines the list of error codes that will respond with this Page in the event that any of the error codes are encountered.
Get the page.
Get a list of URLs which this Page supports. These URLs are used in conjunction with the urls class property.
Note
This function should be overridden by concrete Pages to provide a set of dynamically configured URLs.
The urls property defines the list of URLs that can be used to request this Page.
Note
These URLs should all start with a forward slash.
Example:
urls = ['/index.html', /test/directory/main.html']
Validate all of the properties for this page.
Return True to indicate success, False to indicate failure
The DirectoryFilesPage class provides an implementation of a FilePage which provides the ability to return any file contained within a specific directory.
This class allows the path to the locally stored files to be defined, as well as the HTML directory where the files are located. This class also provides the ability to define a set of extensions used to filter the files returned. Any file that has an extension that is contained within the list of supported extensions will be requested using this Page.
Check that all the required properties are defined.
The path to the locally stored files that this Page will return.
The list of extensions used to filter files that are returned.
Get a list of URLs which this Page supports. These URLs are used in conjunction with the urls class property.
The HTML directory name where the files are stored. This is also the path that will be prefixed to all requests for these pages.
The FilePage class implements a BasePage object which provides the ability for pages to return the content of a file.
Check that all the required properties are defined.
The HtmlPage class provides a base class that returns a page containing text/html content.
Check that all the required properties are defined.
Define the content type for the HtmlPage.
The requests module contains classes pertaining to creating various types of objects to handle HTTP requests.
The BaseRequestHandler class provides the basic functionality that is shared among all HTTP request handlers.
Initialize the request handler.
Log an error message.
The pageClasses property contains the list of Page classes which this request handler is able to provide. The request handler will be able to return requests based on the configured list of URLs for each page, as well as any supported error codes each Page defines.
The server module contains various classes pertaining to creating HTTP servers.
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()
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.