duck.contrib.responses.simple_responseΒΆ

This module provides a shortcut to create a simple response with a given response class and icon link.

Module ContentsΒΆ

FunctionsΒΆ

_make_simple_response

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

_simple_response

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

DataΒΆ

FAVICON

APIΒΆ

duck.contrib.responses.simple_response.FAVICONΒΆ

None

exception duck.contrib.responses.simple_response.SimpleResponseErrorΒΆ

Bases: Exception

Simple response related errors.

Initialization

Initialize self. See help(type(self)) for accurate signature.

duck.contrib.responses.simple_response._make_simple_response(response_class: Type[duck.http.response.HttpResponse], title: str = None, heading: str = None, body: str = None, icon_link: str = None, icon_type='image/png') β†’ duck.http.response.HttpResponseΒΆ

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

Parameters:
  • response_class – The response class to be transformed.

  • title – The title of the response, If not provided, response.status_message is used (optional).

  • heading – The heading of the response. If not provided, response.status_message is used (optional).

  • body – The body of the response. If not provided, response.status_explanation is used (optional).

  • icon_link – The link to the icon (optional).

  • icon_type – The type of the icon (optional).

Raises:
Returns:

The transformed response.

Return type:

HttpResponse

duck.contrib.responses.simple_response._simple_response(response_class: Type[duck.http.response.HttpResponse], title: str = None, heading: str = None, body: str = None, icon_link=FAVICON, icon_type='image/png') β†’ duck.http.response.HttpResponseΒΆ

Transforms a basic response like HttpServerErrorResponse into a nicer simple response.

Parameters:
  • response_class – The response class to be transformed.

  • title – The title of the response, If not provided, response.status_message is used (optional).

  • heading – The heading of the response. If not provided, response.status_message is used (optional).

  • body – The body of the response. If not provided, response.status_explanation is used (optional).

  • icon_link – The link to the icon (optional).

  • icon_type – The type of the icon (optional).

Raises:
Returns:

The transformed response.

Return type:

HttpResponse