def init_app(app: Flask): app.teardown_appcontext(close_db)
from app import app from db import close_db_connection, init_db from controllers import login, logout, add_entry, show_entries app.config.from_object('settings') app.route('/')(show_entries) app.route('/add', methods=['POST'])(add_entry) app.route('/login', methods=['GET', 'POST'])(login) app.route('/logout')(logout) if __name__ == '__main__': app.teardown_appcontext(close_db_connection) init_db(app) app.run()
def init_app(app): """Register database functions with the Flask app. This is called by the application factory. """ app.teardown_appcontext(close_db) app.cli.add_command(init_db_command)
def init_app(app): init_db() app.teardown_appcontext(close_db)
def init_app(app): app.teardown_appcontext(close_db) app.cli.add_command(init_db_command)