Files
Brancheneinstufung2/company-explorer/backend/config.py
Floke 198eaef2b2 feat: Implement unsubscribe link for marketing automation [31188f42]
This commit introduces a new unsubscribe feature to allow contacts to opt-out
from marketing automation.

Key changes include:
- Database schema migration: Added  (UUID) to the  model.
- Data population: Implemented a script to assign unique tokens to existing contacts.
- API endpoint: Created a public GET  endpoint to handle opt-out requests.
- Automation: New contacts automatically receive an unsubscribe token upon creation.
- Integration: The full unsubscribe link is now returned via the provisioning API
  for storage in SuperOffice UDFs (ProgID: SuperOffice:9).
- Documentation: Updated  and
  to reflect the new feature and its integration requirements.
- Added  for quick overview and next steps.
2026-02-24 12:18:13 +00:00

73 lines
2.2 KiB
Python

import os
import logging
from typing import Optional
# Versuche Pydantic zu nutzen, Fallback auf os.environ
try:
from pydantic_settings import BaseSettings
from pydantic import Extra
class Settings(BaseSettings):
# App Info
APP_NAME: str = "Company Explorer"
VERSION: str = "0.7.3"
DEBUG: bool = True
# Database (FINAL CORRECT PATH for Docker Container)
DATABASE_URL: str = "sqlite:////app/companies_v3_fixed_2.db"
# API Keys
GEMINI_API_KEY: Optional[str] = None
OPENAI_API_KEY: Optional[str] = None
SERP_API_KEY: Optional[str] = None
# Paths
LOG_DIR: str = "/app/Log_from_docker"
# Public URL
APP_BASE_URL: str = "http://localhost:8090"
class Config:
env_file = ".env"
extra = 'ignore'
settings = Settings()
except ImportError:
# Fallback wenn pydantic-settings nicht installiert ist
class FallbackSettings:
APP_NAME = "Company Explorer"
VERSION = "0.7.3"
DEBUG = True
DATABASE_URL = "sqlite:////app/companies_v3_fixed_2.db" # FINAL CORRECT PATH
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
SERP_API_KEY = os.getenv("SERP_API_KEY")
LOG_DIR = "/app/Log_from_docker"
settings = FallbackSettings()
# Ensure Log Dir
try:
os.makedirs(settings.LOG_DIR, exist_ok=True)
except FileExistsError:
pass
except Exception as e:
logging.warning(f"Could not create log directory {settings.LOG_DIR}: {e}")
# API Key Loading Helper (from file if env missing)
def load_api_key_from_file(filename: str) -> Optional[str]:
try:
if os.path.exists(filename):
with open(filename, 'r') as f:
return f.read().strip()
except Exception as e:
logging.warning(f"Could not load key from {filename}: {e}")
return None
# Auto-load keys assuming the app runs in the Docker container's /app context
if not settings.GEMINI_API_KEY:
settings.GEMINI_API_KEY = load_api_key_from_file("/app/gemini_api_key.txt")
if not settings.SERP_API_KEY:
settings.SERP_API_KEY = load_api_key_from_file("/app/serpapikey.txt")