karen.shared
Shared library of functions used throughout Karen's various modules
KHTTPRequestHandler
Class to parse an HTTP request into its parts for GET and POST variables, paths, etc. and can handle multipart/form-data requests.
__init__(self, request_text)
special
Request Handler Initialization
Parameters: |
|
---|
parse_GET(self)
Parses the variables from the query string of the HTTP message.
Returns: |
|
---|
parse_POST(self)
Parses the variables from the body of the HTTP message.
Returns: |
|
---|
send_error(self, code, message)
Sets the error code and message for errors.
Parameters: |
|
---|
KJSONRequest
Helper class for storing the portions of an inbound JSON request.
__init__(self, inContainer, inSocket, inPath, inPayload)
special
JSON Request Initialization
Parameters: |
|
---|
sendResponse(self, error=False, message='', data=None, httpStatusCode=200, httpStatusMessage='OK')
Sends an HTTP response to the requesting client to close the connection.
Parameters: |
|
---|
Returns: |
|
---|
dayPart()
Returns the part of the day based on the system time based on generally acceptable breakpoints.
Returns: |
|
---|
sendHTTPResponse(socketConn, responseType='text/html', responseBody='', httpStatusCode=200, httpStatusMessage='OK')
Sends a HTTP response to an open socket connection.
Parameters: |
|
---|
Returns: |
|
---|
sendJSONRequest(url, payLoad)
Sends a JSON request to a specified URL using the POST method.
Parameters: |
|
---|
Returns: |
|
---|
sendJSONResponse(socketConn, error=False, message=None, data=None, httpStatusCode=200, httpStatusMessage='OK')
Sends a JSON package as an HTTP response to an open socket connection. Sends all data as "application/json".
Parameters: |
|
---|
Returns: |
|
---|
threaded(fn)
Thread wrapper shortcut using @threaded prefix
Parameters: |
|
---|
Returns: |
|
---|