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 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 Header class provides the ability to create a specific HTTP header.
Create a content type header.
Get the ID for this header.
Get the operating system from the given headers.
Get the value for this header.
Create a JSON content type header.
Create a location header.
Create an text/html content type header.
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 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