Quivara commited on
Commit
0cb403d
·
verified ·
1 Parent(s): 89281e7

Update alisto_project/backend/ingest_reddit.py

Browse files
alisto_project/backend/ingest_reddit.py CHANGED
@@ -20,7 +20,17 @@ SUBREDDITS = "AlistoSimulation"
20
 
21
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
22
  # loads environment variables from .env file
23
- load_dotenv(os.path.join(BASE_DIR, '../.env'))
 
 
 
 
 
 
 
 
 
 
24
 
25
  # initializes the Flask application context for database access
26
  app = Flask(__name__)
@@ -387,6 +397,12 @@ async def scrape_reddit():
387
  if not client_id or not client_secret:
388
  print("❌ Error: Client ID or Secret missing in .env")
389
  return
 
 
 
 
 
 
390
 
391
  # NEW: Authenticated Login (REQUIRED for Hugging Face)
392
  reddit = asyncpraw.Reddit(
 
20
 
21
  BASE_DIR = os.path.dirname(os.path.abspath(__file__))
22
  # loads environment variables from .env file
23
+ env_path_1 = os.path.join(BASE_DIR, '../.env') # Inside alisto_project
24
+ env_path_2 = os.path.join(BASE_DIR, '../../.env') # In the main root
25
+
26
+ if os.path.exists(env_path_1):
27
+ load_dotenv(env_path_1)
28
+ print("✅ Loaded .env from alisto_project folder")
29
+ elif os.path.exists(env_path_2):
30
+ load_dotenv(env_path_2)
31
+ print("✅ Loaded .env from Root folder")
32
+ else:
33
+ print("⚠️ WARNING: No .env file found! Passwords will be missing.")
34
 
35
  # initializes the Flask application context for database access
36
  app = Flask(__name__)
 
397
  if not client_id or not client_secret:
398
  print("❌ Error: Client ID or Secret missing in .env")
399
  return
400
+
401
+ # DEBUG: Check if password is actually loaded
402
+ if not os.getenv("REDDIT_PASSWORD"):
403
+ print("❌ CRITICAL ERROR: .env file loaded, but REDDIT_PASSWORD is empty/missing!")
404
+ return
405
+
406
 
407
  # NEW: Authenticated Login (REQUIRED for Hugging Face)
408
  reddit = asyncpraw.Reddit(