Skip to content

Commit

Permalink
Make creating dev data be a command
Browse files Browse the repository at this point in the history
Currently you need to set an environment variable and then run the
normal flask run command. It can be difficult to remember the
environment variable and if you forget to remove it then we recreate
the data. Making it a command means it is shown in flask --help and you
can run it directly and it will only create the dev data and exit.
  • Loading branch information
kdeal committed Sep 22, 2023
1 parent a0b84c9 commit f1d56ea
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions api/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from factory import create_app

app = create_app()
Expand All @@ -16,11 +14,14 @@ def teardown_request(*args, **kwargs):
db.session.remove()


if "Development" in os.environ.get("SERVER_SOFTWARE", ""):
@app.cli.command("create-dev-data")
def create_dev_data_entrypoint():
"""Add development data to the configured database"""
from database import db
from tests.conftest import create_dev_data

create_dev_data(db.session)


if __name__ == "__main__":
app.run()

0 comments on commit f1d56ea

Please sign in to comment.