![Flask-Konch screenshot](https://private-user-images.githubusercontent.com/2379650/296312517-9f6b0518-50d3-422f-af63-17c61f7eb7d8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM5Njg5NjMsIm5iZiI6MTcyMzk2ODY2MywicGF0aCI6Ii8yMzc5NjUwLzI5NjMxMjUxNy05ZjZiMDUxOC01MGQzLTQyMmYtYWY2My0xN2M2MWY3ZWI3ZDgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MThUMDgxMTAzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjU4YWVmMjkwNjE2Y2VhNzYwMWM0Zjg1Yzk4ZTAzZDgyNTY5OWYxNWQ1OTQ5NjhlNGEzOTEyZjZkYWYzNTQ4MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.TO-M83k839fJ1M-zXMkiji3wCnL7NUDKBc-wwK2m-JE)
Flask-Konch adds an improved shell command, flask konch
, to the Flask CLI.
- Uses IPython, BPython, or ptpython if available, and falls back to built-in interpreter
- Automatically imports top-level Flask functions and classes by default
- Define additional variables to include in the shell context
- Configurable banner and prompt
Flask-Konch uses konch, a shell configuration utility, under the hood.
pip install flask-konch
To run the shell:
export FLASK_APP=path/to/app.py
flask konch
To add additional variables to the shell context:
app = Flask(__name__)
app.config.update({"KONCH_CONTEXT": {"db": database, "User": User}})
KONCH_FLASK_IMPORTS
: Whether to automatically import top-level Flask functions and classes. Defaults toTrue
.KONCH_FLASK_SHELL_CONTEXT
: Whether to automatically import Flask shell context, as registered by shell_context_processor(f). Defaults toTrue
.KONCH_CONTEXT
: Dictionary of additional variables to include in the shell context.KONCH_SHELL
: May be'ipy'
,'bpy'
,'ptpy'
,'ptipy'
,'py'
, or'auto'
(default).KONCH_BANNER
: Custom banner.KONCH_PROMPT
: Custom input prompt.KONCH_OUTPUT
: Custom output prompt.KONCH_CONTEXT_FORMAT
: Format to display shell context. May be'full'
,'short'
, or a function that receives the context dictionary as input and returns a string.KONCH_IPY_AUTORELOAD
: Whether to load and enable the IPython autoreload extension (must be usingipython
shell).KONCH_IPY_EXTENSIONS
: List of IPython extension names to load (must be usingipython
shell).KONCH_IPY_COLORS
: IPython color style.KONCH_IPY_HIGHLIGHTING_STYLE
: IPython code highlighting style.KONCH_PTPY_VI_MODE
: Enable vi mode (must be usingptpython
shell).
MIT licensed. See the bundled LICENSE file for more details.