From 3fc2ac5235af8a412b5f07aa63191995c9d766fe Mon Sep 17 00:00:00 2001 From: Octopus Date: Mon, 6 Apr 2026 10:43:16 +0800 Subject: [PATCH] fix: use BACKEND_PORT env var in uvicorn and honor base_url arg in searxSearch - api.py: uvicorn.run was hardcoding port=7777 instead of using the port variable populated from BACKEND_PORT env var, making BACKEND_PORT ineffective when running python api.py directly - searxSearch: add missing 'import sys' (caused NameError when run as standalone script) and use constructor base_url arg with env var fallback so searxSearch(base_url=...) actually takes effect --- api.py | 2 +- sources/tools/searxSearch.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api.py b/api.py index 56d3154..080a485 100755 --- a/api.py +++ b/api.py @@ -299,4 +299,4 @@ if __name__ == "__main__": port = int(envport) else: port = 7777 - uvicorn.run(api, host="0.0.0.0", port=7777) \ No newline at end of file + uvicorn.run(api, host="0.0.0.0", port=port) \ No newline at end of file diff --git a/sources/tools/searxSearch.py b/sources/tools/searxSearch.py index 686d3e1..2bc31d0 100644 --- a/sources/tools/searxSearch.py +++ b/sources/tools/searxSearch.py @@ -1,5 +1,6 @@ import requests from bs4 import BeautifulSoup +import sys import os if __name__ == "__main__": # if running as a script for individual testing @@ -16,7 +17,7 @@ class searxSearch(Tools): self.tag = "web_search" self.name = "searxSearch" self.description = "A tool for searching a SearxNG for web search" - self.base_url = os.getenv("SEARXNG_BASE_URL") # Requires a SearxNG base URL + self.base_url = base_url or os.getenv("SEARXNG_BASE_URL") # Requires a SearxNG base URL self.user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36" self.paywall_keywords = [ "Member-only", "access denied", "restricted content", "404", "this page is not working"