fd.write(secret_key) fd.close() except Exception, e: log("Error writing secret cookie key to disk: " + e.message) else: try: fd = open(secret_key_path, "r") secret_key = fd.read() fd.close() except Exception, e: log("Error reading secret cookie key from disk: " + e.message) app.secret_key = secret_key # Get peers from the db app.bootstrap_nodes = [] # Place shared objects on the views base.BaseView.app = app for view in maps.values(): view.db = db view.register(app) view.log = log # Use one file and pass the error type into the context. @app.errorhandler(404) def page_not_found(e): return make_response(render_template('error.html', text="404 - Page not found."), 404) @app.errorhandler(403) def forbidden(e):