middha commited on
Commit
58a7944
Β·
verified Β·
1 Parent(s): 5a04b17

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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 the persistent volume on first run
21
  SRC = os.path.join(os.getcwd(), "instance", "jobs.db")
22
- DST = "/data/jobs.db"
23
  if os.path.exists(SRC) and not os.path.exists(DST):
24
  shutil.copy(SRC, DST)
 
 
 
25
 
26
- # ── 5) Point SQLAlchemy at the persistent file
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)