Skip to main content

Extension to return cats! Works with Flask and Sanic.

Project description

Flask/Sanic error cats (and dogs)

Extension that allows you to return error cats instead of regular error pages.

Extension uses:

Usage

Flask

from error_cats import FlaskErrorCats
from flask import Flask

app = Flask(__name__)
FlaskErrorCats(app, status_codes=set(range(0, 600)), animal='dog')


@app.route('/<int:status_code>')
def status_code_view(status_code):
    return '', status_code


if __name__ == '__main__':
    app.run()

Sanic

from error_cats import SanicErrorCats
from sanic import Sanic
from sanic.response import json

app = Sanic()
SanicErrorCats(app, status_codes=set(range(0, 600)))


@app.route('/<status_code:int>')
async def status_code_view(request, status_code):
    return json('', status=status_code)


if __name__ == '__main__':
    app.run()

Available parameters

param default value
app None (can be configured later) Web application (Flask or Sanic)
animal cat Available values: cat, dog
status_codes 400...599 Container with status codes that should be translated into cats
simple_html_template ... Simple python format string (html). Should contain {status_cde} (int) and {image} (url)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Error-Cats, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size Error_Cats-0.1.0-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size Error Cats-0.1.0.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page