API¶
Flask-Nicely is comprised of two main modules, the decorator
module and
the errors
module.
decorator
Module¶
The decorator
module is the core function of the package.
-
flask_nicely.decorators.
nice_json
(func)¶ A decorator which returns a pretty jsonified response when wrapped around a Flask view function.
Parameters: func – the Flask view function to be wrapped Return type: flask.Response
errors
Module¶
The errors
module contains a collection of exceptions that will
generate corresponding Flask HTTP responses when raised in a function.
-
exception
flask_nicely.errors.
Forbidden
(error_message='', payload=None, *args, **kwargs)¶ Bases:
flask_nicely.errors.HTTPError
A 403 Forbidden HTTP error.
-
status_code
= 403¶
-
-
exception
flask_nicely.errors.
GatewayTimeout
(error_message='', payload=None, *args, **kwargs)¶ Bases:
flask_nicely.errors.HTTPError
A 504 Gateway Timeout HTTP error.
-
status_code
= 504¶
-
-
exception
flask_nicely.errors.
HTTPError
(error_message='', payload=None, *args, **kwargs)¶ Bases:
exceptions.Exception
A generic error mixin from which the HTTP error responses inherit.
-
get_response
()¶
-
status_code
= None¶
-
-
exception
flask_nicely.errors.
NotFound
(error_message='', payload=None, *args, **kwargs)¶ Bases:
flask_nicely.errors.HTTPError
A 404 Not Found HTTP error.
-
status_code
= 404¶
-
-
exception
flask_nicely.errors.
ServerError
(error_message='', payload=None, *args, **kwargs)¶ Bases:
flask_nicely.errors.HTTPError
A 500 Internal Server Error HTTP error.
-
status_code
= 500¶
-
Bases:
flask_nicely.errors.HTTPError
A 401 Unauthorized HTTP error.