Skip to content

Instantly share code, notes, and snippets.

@dario61081
Created December 8, 2023 14:49
Show Gist options
  • Save dario61081/251ac932a1ab40b9d205b1c193c2abcc to your computer and use it in GitHub Desktop.
Save dario61081/251ac932a1ab40b9d205b1c193c2abcc to your computer and use it in GitHub Desktop.
example of command in flask
from click import echo
@app.cli.command('init_db')
def initialize_database():
"""Initialize the SQLite database."""
database.drop_all()
database.create_all()
click.echo('Initialized the SQLite database!')
# in terminal
$ flask init_db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment