Update app.py
Browse files
app.py
CHANGED
|
@@ -17,15 +17,19 @@ app = Flask(__name__)
|
|
| 17 |
app.logger.handlers = logger.handlers
|
| 18 |
app.logger.setLevel(logger.level)
|
| 19 |
|
| 20 |
-
# ββ 4) Copy your committed DB into
|
| 21 |
SRC = os.path.join(os.getcwd(), "instance", "jobs.db")
|
| 22 |
-
DST = "/
|
| 23 |
if os.path.exists(SRC) and not os.path.exists(DST):
|
| 24 |
shutil.copy(SRC, DST)
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
# ββ 5) Point SQLAlchemy at the
|
| 27 |
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{DST}"
|
| 28 |
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
|
|
|
| 29 |
app.secret_key = os.getenv("SECRET_KEY", "change_me")
|
| 30 |
|
| 31 |
db = SQLAlchemy(app)
|
|
|
|
| 17 |
app.logger.handlers = logger.handlers
|
| 18 |
app.logger.setLevel(logger.level)
|
| 19 |
|
| 20 |
+
# ββ 4) Copy your committed DB into /tmp on first run
|
| 21 |
SRC = os.path.join(os.getcwd(), "instance", "jobs.db")
|
| 22 |
+
DST = "/tmp/jobs.db"
|
| 23 |
if os.path.exists(SRC) and not os.path.exists(DST):
|
| 24 |
shutil.copy(SRC, DST)
|
| 25 |
+
# if you want an empty DB file to be created on first run:
|
| 26 |
+
elif not os.path.exists(DST):
|
| 27 |
+
open(DST, "a").close()
|
| 28 |
|
| 29 |
+
# ββ 5) Point SQLAlchemy at the tmp file
|
| 30 |
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite:///{DST}"
|
| 31 |
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
| 32 |
+
|
| 33 |
app.secret_key = os.getenv("SECRET_KEY", "change_me")
|
| 34 |
|
| 35 |
db = SQLAlchemy(app)
|