From 7f80eb1e51eb6e1a71815f5542572571c24cbab8 Mon Sep 17 00:00:00 2001 From: Don-Swanson <32144818+Don-Swanson@users.noreply.github.com> Date: Sun, 21 Sep 2025 00:11:54 -0500 Subject: [PATCH] feat(beta): httpx migration, Tor/proxy refactor, JSON results, alt-link fixes, tests, optional static bundling, HTTP/2 env toggle, cleanup --- .pre-commit-config.yaml | 13 ++++ README.md | 33 ++++++++++ app/__init__.py | 58 ++++++++++++++++ app/filter.py | 120 +++++++++++++++++++++++----------- app/request.py | 29 ++++---- app/routes.py | 68 +++++++++++++++---- app/services/__init__.py | 2 + app/services/http_client.py | 107 ++++++++++++++++++++++++++++++ app/services/provider.py | 40 ++++++++++++ app/templates/display.html | 26 +++++--- app/templates/error.html | 4 ++ app/templates/header.html | 4 ++ app/templates/index.html | 20 ++++-- app/utils/bangs.py | 11 ++-- app/utils/misc.py | 6 +- app/utils/search.py | 12 ++-- misc/update-translations.py | 4 +- pyproject.toml | 13 ++++ requirements.txt | 9 ++- setup.cfg | 2 +- test/test_alts.py | 110 +++++++++++++++++++++++++++++++ test/test_autocomplete_xml.py | 29 ++++++++ test/test_http_client.py | 33 ++++++++++ test/test_json.py | 73 +++++++++++++++++++++ test/test_results.py | 41 ++++++++---- test/test_routes_json.py | 26 ++++++++ test/test_tor.py | 45 +++++++++++++ 27 files changed, 825 insertions(+), 113 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 app/services/__init__.py create mode 100644 app/services/http_client.py create mode 100644 app/services/provider.py create mode 100644 test/test_alts.py create mode 100644 test/test_autocomplete_xml.py create mode 100644 test/test_http_client.py create mode 100644 test/test_json.py create mode 100644 test/test_routes_json.py create mode 100644 test/test_tor.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b90d821 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.9 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + - repo: https://github.com/psf/black + rev: 24.8.0 + hooks: + - id: black + args: [--quiet] + diff --git a/README.md b/README.md index 22f177a..71695ee 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ Contents - User-defined [custom bangs](#custom-bangs) - Optional location-based searching (i.e. results near \) - Optional NoJS mode to view search results in a separate window with JavaScript blocked +- JSON output for results via content negotiation (see "JSON results (API)") *No third party JavaScript. Whoogle can be used with JavaScript disabled, but if enabled, uses JavaScript for things like presenting search suggestions. @@ -463,6 +464,8 @@ There are a few optional environment variables available for customizing a Whoog | WHOOGLE_SHOW_FAVICONS | Show/hide favicons next to search result URLs. Default on. | | WHOOGLE_UPDATE_CHECK | Enable/disable the automatic daily check for new versions of Whoogle. Default on. | | WHOOGLE_FALLBACK_ENGINE_URL | Set a fallback Search Engine URL when there is internal server error or instance is rate-limited. Search query is appended to the end of the URL (eg. https://duckduckgo.com/?k1=-1&q=). | +| WHOOGLE_BUNDLE_STATIC | When set to 1, serve a single bundled CSS and JS file generated at startup to reduce requests. Default off. | +| WHOOGLE_HTTP2 | Enable HTTP/2 for upstream requests (via httpx). Default on — set to 0 to force HTTP/1.1. | ### Config Environment Variables These environment variables allow setting default config values, but can be overwritten manually by using the home page config menu. These allow a shortcut for destroying/rebuilding an instance to the same config state every time. @@ -495,6 +498,28 @@ Same as most search engines, with the exception of filtering by time range. To filter by a range of time, append ":past