Skip to main content

A profanity censor with hooks for Flask and Jinja2

Project description


A profanity censor by Rob Heath with hooks for Flask and Jinja2, based on profanity by Ben Friedland and flask-recaptcha by mardix.


pip install flask-censor


The module can be used standalone (as profanity is), or can be integrated into a Flask app for use in Jinja2 templates.


In your Flask code, link flask-censor to your Flask app as so:

from flask import Flask
from flask_censor import Censor

app = Flask(__name__)
censor = Censor(app=app)

# or if adding app later:

censor = Censor()


When integrated with Flask the module provides a template filter censor accessible through Jinja2 templates using the filter pipe:

<h1> {{ data_from_flask|censor }} </h1>


If integrated with Flask, the following config variables control behaviour:

CENSOR_WORDLIST: path to file from which to read the word list for censorship

CENSOR_CHARACTERS: string of values to use in place of censored word

If not integrating with Flask, these can be set using the keyword arguments wordlist and censorchars when instantiating the class.


censor.init_app(app=app) initialises flask-censor to a Flask app instance

censor.import_wordlist(wordlist) imports a new word list from the file at path wordlist

censor.censor(input_string) goes over the input string, replacing sub-strings from the word list with sensor characters from the censor character pool

censor.set_censorchars(censorchars) sets the pool of characters to use for censoring words from the word list

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for flask-censor, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size flask_censor-0.1-py3-none-any.whl (4.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flask-censor-0.1.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page