Created
December 8, 2023 14:49
-
-
Save dario61081/251ac932a1ab40b9d205b1c193c2abcc to your computer and use it in GitHub Desktop.
example of command in flask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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