update
This commit is contained in:
52
backend/config.py
Normal file
52
backend/config.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
from pathlib import Path
|
||||
|
||||
# Get the directory where this script is located
|
||||
backend_dir = Path(__file__).parent
|
||||
env_path = backend_dir / '.env'
|
||||
|
||||
# Load .env file
|
||||
load_dotenv(dotenv_path=env_path)
|
||||
|
||||
# Debug: Print if .env file exists (for troubleshooting)
|
||||
if env_path.exists():
|
||||
print(f"✓ Loading .env file from: {env_path}")
|
||||
else:
|
||||
print(f"⚠ Warning: .env file not found at {env_path}")
|
||||
print(f" Current working directory: {os.getcwd()}")
|
||||
print(f" Looking for .env in: {env_path}")
|
||||
|
||||
|
||||
class Config:
|
||||
"""Application configuration"""
|
||||
|
||||
# MongoDB
|
||||
MONGODB_URI = os.getenv('MONGODB_URI', 'mongodb://localhost:27017/')
|
||||
DB_NAME = 'munich_news'
|
||||
|
||||
# Email
|
||||
SMTP_SERVER = os.getenv('SMTP_SERVER', 'smtp.gmail.com')
|
||||
SMTP_PORT = int(os.getenv('SMTP_PORT', '587'))
|
||||
EMAIL_USER = os.getenv('EMAIL_USER', '')
|
||||
EMAIL_PASSWORD = os.getenv('EMAIL_PASSWORD', '')
|
||||
|
||||
# Ollama
|
||||
OLLAMA_BASE_URL = os.getenv('OLLAMA_BASE_URL', 'http://localhost:11434')
|
||||
OLLAMA_MODEL = os.getenv('OLLAMA_MODEL', 'llama2')
|
||||
OLLAMA_API_KEY = os.getenv('OLLAMA_API_KEY', '')
|
||||
OLLAMA_ENABLED = os.getenv('OLLAMA_ENABLED', 'false').lower() == 'true'
|
||||
|
||||
# Flask
|
||||
FLASK_PORT = int(os.getenv('FLASK_PORT', '5000'))
|
||||
|
||||
@classmethod
|
||||
def print_config(cls):
|
||||
"""Print configuration (without sensitive data)"""
|
||||
print("\nApplication Configuration:")
|
||||
print(f" MongoDB URI: {cls.MONGODB_URI}")
|
||||
print(f" Database: {cls.DB_NAME}")
|
||||
print(f" Flask Port: {cls.FLASK_PORT}")
|
||||
print(f" Ollama Base URL: {cls.OLLAMA_BASE_URL}")
|
||||
print(f" Ollama Model: {cls.OLLAMA_MODEL}")
|
||||
print(f" Ollama Enabled: {cls.OLLAMA_ENABLED}")
|
||||
Reference in New Issue
Block a user