jobbler commited on
Commit
148aa89
·
1 Parent(s): ad48fd7

Save study.db to writable /tmp or /data directory

Browse files
Files changed (1) hide show
  1. main.py +4 -1
main.py CHANGED
@@ -27,7 +27,10 @@ def read_root():
27
  return RedirectResponse(url="/static/index.html")
28
 
29
  # --- SQLite Database Setup ---
30
- DB_FILE = "study.db"
 
 
 
31
 
32
  def init_db():
33
  conn = sqlite3.connect(DB_FILE)
 
27
  return RedirectResponse(url="/static/index.html")
28
 
29
  # --- SQLite Database Setup ---
30
+ # Hugging Face Spaces make the /app directory read-only by default.
31
+ # We must write the database to /data (if persistent storage is enabled) or /tmp.
32
+ DB_DIR = "/data" if os.path.exists("/data") else "/tmp"
33
+ DB_FILE = os.path.join(DB_DIR, "study.db")
34
 
35
  def init_db():
36
  conn = sqlite3.connect(DB_FILE)