create_app#

scikitplot.cleanprompt.create_app(policy=None, secret_key=None, ephemeral_secret_key=False, store=None, enable_ner=False, ner_model=None, ner_engine='auto', language='en', model_size='sm', hide_terms=(), word_boundary=False, session_cookie_secure=False, config=None)[source]#

Build the Flask application.

Parameters:
policyRedactionPolicy, optional

Redaction configuration. Defaults to DEFAULT_POLICY.

secret_keystr, optional

Flask session signing key. Falls back to CLEANPROMPT_SECRET_KEY.

ephemeral_secret_keybool, default=False

Permit a per-process random key when none is configured. Sessions then do not survive a restart and do not work across workers.

storeSessionStore, optional

Vault store. A new bounded store is created when omitted.

enable_nerbool, default=False

Also run named-entity detection, with the engine ner_engine selects. Every selected engine must be ready (package, language and data), or the app refuses to start.

ner_modelstr, optional

Explicit spaCy model, overriding language and model_size.

ner_enginestr, default=’auto’

Entity engine: auto, spacy, nltk, both or none.

languagestr, default=’en’

Language code for entity detection.

model_sizestr, default=’sm’

Preferred spaCy model size.

hide_termstuple of str, default=()

Exact strings hidden on every request, in addition to whatever the visitor types into the form.

word_boundarybool, default=False

Whether hide_terms match only at word boundaries.

session_cookie_securebool, default=False

Set the Secure cookie flag. Defaults to False because the app is served over plain HTTP on loopback; set it when placing the app behind TLS.

configdict, optional

Extra Flask configuration applied last.

Returns:
flask.Flask

The configured application.

Raises:
CapabilityError

If the web tier is unavailable, or enable_ner is set and the requested entity engine is not ready; the message names each engine’s reason and remedy.

PolicyError

If no secret key is configured and ephemeral_secret_key is not set.

Parameters:
Return type:

Any

Notes

Developer notes. Every route is registered on a local app; there is no module-level application object, so importing this module has no side effects and a test can build as many isolated apps as it needs.