本文整理汇总了Python中flask.app.Flask.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Flask.debug方法的具体用法?Python Flask.debug怎么用?Python Flask.debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.app.Flask
的用法示例。
在下文中一共展示了Flask.debug方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_app
# 需要导入模块: from flask.app import Flask [as 别名]
# 或者: from flask.app.Flask import debug [as 别名]
def make_app(import_name=__name__, config="homebank.settings.Configuration", debug=False):
app = Flask(import_name)
app.config.from_object(config)
app.config.from_envvar("FLASK_SETTINGS", silent=True)
app.debug = debug
app.jinja_env.filters["currency"] = lambda x: "{:,.2f} %s".format(x).replace(",", " ").replace(".", ",") % (
app.config.get("CURRENCY", "")
)
if app.debug:
import_string("flask.ext.debugtoolbar:DebugToolbarExtension")(app)
@app.errorhandler(404)
def not_found(ex):
return render_template("404.html"), 404
for blueprint in ["__init__", "accounts", "transactions"]:
app.register_blueprint(import_string("homebank.blueprints.%s:root" % blueprint))
login_manager = LoginManager(app=app)
login_manager.login_view = "index.login"
login_manager.session_protection = "strong"
@login_manager.user_loader
def load_user(uid):
if uid != app.config["PINCODE"]:
return None
return User()
if not app.debug:
handler = StreamHandler()
if "ERROR_LOG" in app.config:
handler = WatchedFileHandler(app.config["ERROR_LOG"])
handler.setLevel(WARNING)
handler.setFormatter(Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
app.logger.addHandler(handler)
return app
示例2: Flask
# 需要导入模块: from flask.app import Flask [as 别名]
# 或者: from flask.app.Flask import debug [as 别名]
from flask.app import Flask
from flask.ext.admin.base import MenuLink
import settings
from todo_app.admin_views import AdminIndex
from werkzeug.debug import DebuggedApplication
from flask_admin import Admin
from google.appengine.api import users
flask_app = Flask(__name__)
flask_app.config.from_object(settings)
admin = Admin(flask_app, name='TODO', index_view=AdminIndex(url='/admin', name='Home'), )
admin.add_link(MenuLink(name='Logout',url = users.create_logout_url('/')))
if flask_app.config['DEBUG']:
flask_app.debug = True
app = DebuggedApplication(flask_app, evalex=True)
app = flask_app
from todo_app import admin_views
from todo_app import views
示例3: queue_send
# 需要导入模块: from flask.app import Flask [as 别名]
# 或者: from flask.app.Flask import debug [as 别名]
from flask.globals import request
from zaguan.examples.colors.controller import ColorsController
_msg_queue = []
def queue_send(msg):
_msg_queue.append(msg)
if __name__ == '__main__':
controller = ColorsController()
controller.send_function = queue_send
app = Flask(__name__, static_folder="html")
app.add_url_rule('/<path:filename>', endpoint='static',
view_func=app.send_static_file)
app.debug = True
@app.route("/")
def index(module=None):
html = open("html/index.html").read()
return html + '<script src="js/debug.js" type="text/javascript"></script>'
@app.route("/colors/<action>")
def actions(action):
controller.process_uri(request.url)
return ""
@app.route("/debug/messages")
def debug_send():
global _msg_queue
messages = "\n".join(_msg_queue)