Files
Reklamator/config/development.py
T
gurixandClaude 51d1740bc0 Fix configuration architecture: Add dotenv loading and use app.config consistently
Address architectural inconsistency where environment variables were used
directly instead of through Flask's configuration system.

Issues Fixed:
1. .env file was never loaded - load_dotenv() was missing
2. Routes used os.getenv() directly instead of app.config
3. ANTHROPIC_API_KEY was defined in config but not used properly

Changes:
- config/development.py: Added load_dotenv() at module level
- app/routes/submission.py: Changed os.getenv() to current_app.config.get()
- app/routes/dashboard.py: Changed os.getenv() to current_app.config.get()

Benefits:
- Proper separation of concerns (config vs code)
- .env files now work as expected in development
- Easier to test (can mock app.config)
- Consistent with Flask best practices
- Production env vars still work (no dotenv in production config)

Configuration Flow:
Development: .env → load_dotenv() → os.environ → DevelopmentConfig → app.config
Production:  System env vars → os.environ → ProductionConfig → app.config
Application: app.config.get('ANTHROPIC_API_KEY')

All 49 tests passing (1 skipped)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-17 09:45:31 +02:00

42 lines
1.2 KiB
Python

"""Development configuration"""
import os
from dotenv import load_dotenv
# Load .env file for development
load_dotenv()
class DevelopmentConfig:
"""Development environment configuration"""
DEBUG = True
TESTING = False
# Security
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-change-in-production')
# Paths
DATA_DIR = os.environ.get('DATA_DIR', './data')
# Flask-WTF CSRF
WTF_CSRF_ENABLED = True
WTF_CSRF_TIME_LIMIT = None
# File Upload
MAX_CONTENT_LENGTH = int(os.environ.get('MAX_CONTENT_LENGTH', 10 * 1024 * 1024)) # 10MB
# AI Integration
ANTHROPIC_API_KEY = os.environ.get('ANTHROPIC_API_KEY')
# ClamAV
CLAMD_SOCKET = os.environ.get('CLAMD_SOCKET', '/var/run/clamav/clamd.ctl')
# Rate Limiting
RATELIMIT_ENABLED = os.environ.get('RATE_LIMIT_ENABLED', 'true').lower() == 'true'
RATELIMIT_STORAGE_URL = 'memory://'
RATELIMIT_PER_HOUR = int(os.environ.get('RATE_LIMIT_PER_HOUR', 10))
# Session
SESSION_COOKIE_SECURE = False # Allow HTTP in development
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = 'Lax'
PERMANENT_SESSION_LIFETIME = 86400 # 24 hours