Snippets are unofficial and unmaintained.
This is an archived view of user-submitted snippets. Despite being hosted on the Flask site, they are not official. No Flask maintainer has curated or checked the snippets for security, correctness, or design.
The documentation recommends putting imports in a module and import that when you're in an interactive session. Even better, I think, is to make an executable that launches a preconfigured Python shell.
Put something like this in for example
shell.py and run
chmod +x shell.py.
#!/usr/bin/env python import os import readline from pprint import pprint from flask import * from myapp import * from utils import * from db import * from models import * os.environ['PYTHONINSPECT'] = 'True'
import * should be avoided but unless you get namespace collisions it makes sense for an interactive shell environment.
Now you can simply do
This snippet by Dag Odenhall can be used freely for anything you like. Consider it public domain.