The requests module

The requests module contains classes pertaining to creating various types of objects to handle HTTP requests.

The StatusCodes class

Inheritance diagram of pyamp.web.http.requests.StatusCodes

class pyamp.web.http.requests.StatusCodes

The StatusCodes class contains constants pertaining to HTTP status codes.

FileNotFound

The file not found status code.

Found

The found status code.

InternalServerError

The internal server error status code.

MovedPermanently

The moved permanently status code.

OK

The OK status code.

The Keys class

Inheritance diagram of pyamp.web.http.requests.Keys

class pyamp.web.http.requests.Keys

The Keys class defines constants that are used as keys to access certain dictionary values.

ErrorMessage

The key for the entry containing the error message.

The NotFoundPage class

Inheritance diagram of pyamp.web.http.requests.NotFoundPage

class pyamp.web.http.requests.NotFoundPage

The NotFoundPage is displayed in the event that a requested page was not found.

Check that all the required properties are defined.

errorCodes

Define the list of error codes which will display this page.

The StoppableRequestHandler class

Inheritance diagram of pyamp.web.http.requests.StoppableRequestHandler

class pyamp.web.http.requests.StoppableRequestHandler(request, client_address, server)[source]

The StoppableRequestHandler class provides an implementation of an HTTP request handler that handles the quit message send by a server when it is trying to stop itself.

do_QUIT()[source]

Handle a QUIT message.

The InternalServerErrorPage class

Inheritance diagram of pyamp.web.http.requests.InternalServerErrorPage

class pyamp.web.http.requests.InternalServerErrorPage

The InternalServerErrorPage is displayed in the event that an internal server error is encountered during processing. It provides the ability to display the encountered error to the user.

Check that all the required properties are defined.

errorCodes

Define the list of error codes which will display this page.

The Header class

Inheritance diagram of pyamp.web.http.requests.Header

class pyamp.web.http.requests.Header(identifier, value)

The Header class provides the ability to create a specific HTTP header.

  • identifier – The header identifier
  • value – The value for the header
classmethod contentType(contentType)

Create a content type header.

  • contentType – The type of content
getId()

Get the ID for this header.

classmethod getOperatingSystem(headers)

Get the operating system from the given headers.

  • headers – The headers
getValue()

Get the value for this header.

classmethod jsonContent()

Create a JSON content type header.

classmethod location(location)

Create a location header.

  • location – The location
classmethod textHtmlContent()

Create an text/html content type header.

The BaseRequestHandler class

Inheritance diagram of pyamp.web.http.requests.BaseRequestHandler

class pyamp.web.http.requests.BaseRequestHandler(request, client_address, server)[source]

The BaseRequestHandler class provides the basic functionality that is shared among all HTTP request handlers.

do_GET()[source]

Process a GET request.

do_POST()[source]

Process a POST request.

classmethod initialize(*args, **kwargs)

Initialize the request handler.

  • args – Additional arguments
  • kwargs – Additional keyword arguments
logError(message)

Log an error message.

  • message – The message to log
pageClasses

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.