Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A man is not dead while his name is still spoken.

Project description

Flask-Clacks

https://img.shields.io/pypi/v/flask-clacks.svg https://img.shields.io/travis/WilliamMayor/flask-clacks.svg Documentation Status

A man is not dead while his name is still spoken.

This is a very simple Flask extension that adds ‘X-Clacks-Overhead’ headers to your website’s responses.

Features

This package exposes a Flask extension which by default adds the header X-Clacks-Overhead: GNU Terry Pratchett on all routes, for all origins and methods.

  • You can add extra names to your overhead
  • You can decorate individual routes to have the overhead

Installation

Install the extension with using pip, or easy_install.

$ pip install -U flask-clacks

Usage

Apply to all routes, sending only Terry Pratchett’s name in the overhead.

from flask import Flask
from flask-clacks import Clacks

app = Flask(__name__)
Clacks(app)

@app.route("/")
def index():
    # Will have the header added to the response
    return "OK"

Apply to all routes, sending Terry Pratchett and John Dearheart’s names in the overhead.

from flask import Flask
from flask-clacks import Clacks

app = Flask(__name__)
Clacks(app, names=('John Dearheart', ))

@app.route("/")
def index():
    # Will have the the clacks overhead header for both Terry and John
    return "OK"

Apply to specific routes, sending different names back on different responses.

from flask import Flask
from flask-clacks import clacks

app = Flask(__name__)

@app.route("/terry/")
@clacks
def terry():
    # Will have a clacks overhead header for Terry
    return "OK"

@app.route("/terry-and-john/")
@clacks(names=('John Dearheart', ))
def terry_and_john():
    # Will have a clacks overhead header for both Terry and John
    return "OK"

@app.route("/no-one/")
def no_one():
    # Will not have clacks overhead headers
    return "OK"

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Thanks go to the Flask-CORS extension for providing decent examples of how to package an extension.

History

1.0.0 (2017-04-26)

  • First release on PyPI.

1.0.1 (2017-04-26)

  • Learning how things like travis, PyPI, and tox work
  • Fixing small config things

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 flask-clacks, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size flask_clacks-1.0.1-py2.py3-none-any.whl (5.1 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size flask-clacks-1.0.1.tar.gz (12.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page