Mina commited on
Commit
87d3243
·
1 Parent(s): 25ae7fe

Fix: Move DB to /tmp and optimize health checks for HF

Browse files
Files changed (2) hide show
  1. database.py +5 -1
  2. main.py +5 -6
database.py CHANGED
@@ -1,7 +1,11 @@
1
  import aiosqlite
2
  import logging
3
 
4
- DB_NAME = "netflix_clone.db"
 
 
 
 
5
 
6
  async def init_db():
7
  async with aiosqlite.connect(DB_NAME) as db:
 
1
  import aiosqlite
2
  import logging
3
 
4
+ import os
5
+
6
+ # Hugging Face Spaces have a read-only filesystem except for /tmp
7
+ is_hf = os.environ.get("SPACE_ID") is not None or os.environ.get("HF_SPACE") is not None
8
+ DB_NAME = "/tmp/netflix_clone.db" if is_hf else "netflix_clone.db"
9
 
10
  async def init_db():
11
  async with aiosqlite.connect(DB_NAME) as db:
main.py CHANGED
@@ -93,12 +93,11 @@ app.add_middleware(GZipMiddleware, minimum_size=1000)
93
 
94
  @app.get("/")
95
  async def root():
96
- return {
97
- "status": "online",
98
- "engine": "Nitro-Power Larooza Engine",
99
- "engine_status": "WARM" if scraper._cookies_synced else "COLD",
100
- "cached_keys": list(cache._cache.keys())
101
- }
102
 
103
  @app.get("/latest")
104
  async def get_latest(page: int = 1):
 
93
 
94
  @app.get("/")
95
  async def root():
96
+ return {"status": "ok", "message": "MEIH Movies API is running"}
97
+
98
+ @app.get("/health")
99
+ async def health():
100
+ return {"status": "online", "timestamp": time.time()}
 
101
 
102
  @app.get("/latest")
103
  async def get_latest(page: int = 1):