예제 #1
0
def init_app(app: Flask):
    # Register database functions with the Flask app
    if not os.path.isdir(app.instance_path):
        # Create the instance directory if it doesn't exist already
        os.mkdir(app.instance_path)
    db_path = os.path.dirname(app.config["DATABASE"])
    if not os.path.isdir(db_path):
        # Create the db directory if it doesn't exist already
        os.mkdir(db_path)
    app.teardown_appcontext(close_db)
    app.cli.add_command(init_db_command)
예제 #2
0
 def init_app(self, app: Flask) -> None:
     if hasattr(app, 'teardown_appcontext'):
         app.teardown_appcontext(self.teardown)
     else:
         app.teardown_request(self.teardown)
     self.add_custom_template_filters(app)
예제 #3
0
def init_app(app: Flask):
    app.teardown_appcontext(close_db)
    app.cli.add_command(init_db_command)
    pass