~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: Use settings framework for web server configuration
LearningCircuit16cfc1e4c9a4
diff --git a/src/local_deep_research/web/app.py b/src/local_deep_research/web/app.pyindex fe9cf2a36c..0f432ee3e5 100644--- a/src/local_deep_research/web/app.py+++ b/src/local_deep_research/web/app.py@@ -16,16 +16,15 @@ def main():# Create the Flask app and SocketIO instanceapp, socket_service = create_app()- # Get web server settings from environment or use defaults- # Can't use database here because Flask app context isn't established yet- import os-- port = int(os.environ.get("LDR_PORT", "5000"))- host = os.environ.get("LDR_HOST", "0.0.0.0")- debug = os.environ.get("LDR_DEBUG", "true").lower() == "true"- use_https = (- os.environ.get("LDR_USE_HTTPS", "true").lower() == "true"- ) # Default to HTTPS+ # Get web server settings from configuration file or environment+ # This allows settings to be configured through the web UI+ from .server_config import load_server_config++ config = load_server_config()+ host = config["host"]+ port = config["port"]+ debug = config["debug"]+ use_https = config["use_https"]if use_https:# For development, use self-signed certificatediff --git a/src/local_deep_research/web/routes/settings_routes.py b/src/local_deep_research/web/routes/settings_routes.pyindex d56e3ee228..957a0f4233 100644--- a/src/local_deep_research/web/routes/settings_routes.py+++ b/src/local_deep_research/web/routes/settings_routes.py@@ -706,6 +706,17 @@ def api_update_setting(key):# Pass the db_session to avoid session lookup issuessuccess = set_setting(key, value, db_session=db_session)if success:+ # Sync server config if web settings were updated+ if key in ["web.host", "web.port"]:+ from ..server_config import sync_from_settings+ from ..services.settings_manager import SettingsManager++ settings_manager = SettingsManager(db_session)+ settings_snapshot = (+ settings_manager.get_settings_snapshot()+ )+ sync_from_settings(settings_snapshot)+response_data = {"message": f"Setting {key} updated successfully"}@@ -765,6 +776,17 @@ def api_update_setting(key):)if db_setting:+ # Sync server config if web settings were updated+ if key in ["web.host", "web.port"]:+ from ..server_config import sync_from_settings+ from ..services.settings_manager import SettingsManager++ settings_manager = SettingsManager(db_session)+ settings_snapshot = (+ settings_manager.get_settings_snapshot()+ )+ sync_from_settings(settings_snapshot)+return (jsonify({diff --git a/src/local_deep_research/web/server_config.py b/src/local_deep_research/web/server_config.pynew file mode 100644index 0000000000..eb328ff2e2--- /dev/null+++ b/src/local_deep_research/web/server_config.py@@ -0,0 +1,96 @@+"""Server configuration management for web app startup.++This module handles server configuration that needs to be available before+Flask app context is established. It provides a bridge between environment+variables and database settings.+"""++import json+import os+from pathlib import Path+from typing import Dict, Any++from loguru import logger++from ..config.paths import get_data_dir+++def get_server_config_path() -> Path:+ """Get the path to the server configuration file."""+ return get_data_dir() / "server_config.json"+++def load_server_config() -> Dict[str, Any]:+ """Load server configuration from file or environment variables.++ Returns:+ dict: Server configuration with keys: host, port, debug, use_https+ """+ config_path = get_server_config_path()++ # Default configuration+ config = {"host": "0.0.0.0", "port": 5000, "debug": True, "use_https": True}++ # Try to load from config file first+ if config_path.exists():+ try:+ with open(config_path, "r") as f:+ saved_config = json.load(f)+ config.update(saved_config)+ logger.debug(f"Loaded server config from {config_path}")+ except Exception as e:+ logger.warning(f"Failed to load server config: {e}")++ # Environment variables override file settings+ if "LDR_HOST" in os.environ:+ config["host"] = os.environ["LDR_HOST"]+ if "LDR_PORT" in os.environ:+ config["port"] = int(os.environ["LDR_PORT"])+ if "LDR_DEBUG" in os.environ:+ config["debug"] = os.environ["LDR_DEBUG"].lower() == "true"+ if "LDR_USE_HTTPS" in os.environ:+ config["use_https"] = os.environ["LDR_USE_HTTPS"].lower() == "true"++ return config+++def save_server_config(config: Dict[str, Any]) -> None:+ """Save server configuration to file.++ This should be called when web.host or web.port settings are updated+ through the UI.++ Args:+ config: Server configuration dict+ """+ config_path = get_server_config_path()++ try:+ # Ensure directory exists+ config_path.parent.mkdir(parents=True, exist_ok=True)++ with open(config_path, "w") as f:+ json.dump(config, f, indent=2)++ logger.info(f"Saved server config to {config_path}")+ except Exception as e:+ logger.exception(f"Failed to save server config: {e}")+++def sync_from_settings(settings_snapshot: Dict[str, Any]) -> None:+ """Sync server config from settings snapshot.++ This should be called when settings are updated through the UI.++ Args:+ settings_snapshot: Settings snapshot containing web.host and web.port+ """+ config = load_server_config()++ # Update from settings if available+ if "web.host" in settings_snapshot:+ config["host"] = settings_snapshot["web.host"]+ if "web.port" in settings_snapshot:+ config["port"] = settings_snapshot["web.port"]++ save_server_config(config)