Extended Types

Back to top

This module implements the type extensions applied by SearXNG.


searx.extended_types.sxng_request: SXNG_Request : A replacement for flask.request with type cast SXNG_Request.

class searx.extended_types.SXNG_Request(environ: WSGIEnvironment, populate_request: bool = True, shallow: bool = False)[source] : SearXNG extends the class flask.Request with properties from this class definition, see type cast sxng_request.

user\_plugins: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]
:   list of searx.plugins.Plugin.id (the id of the plugins)

preferences: searx.preferences.Preferences
:   The preferences of the request.

errors: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]
:   A list of errors (translated text) added by `searx.webapp` in
    case of errors.

start\_time: [float](https://docs.python.org/3/builtins/functions.html#float)
:   Start time of the request, [`timeit.default_timer`](https://docs.python.org/3/library/timeit.html#timeit.default_timer) added by
    `searx.webapp` to calculate the total time of the request.

render\_time: [float](https://docs.python.org/3/builtins/functions.html#float)
:   Duration of the rendering, calculated and added by
    `searx.webapp`.

timings: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[searx.results.Timing]
:   A list of `searx.results.Timing` of the engines, calculatid in
    and hold by `searx.results.ResultContainer.timings`.

remote\_addr: [str](https://docs.python.org/3/builtins/stdtypes.html#str)
:   The address of the client sending the request.

class searx.extended_types.SXNG_Response(curl: Curl | None = None, request: Request | None = None)[source] : SearXNG extends curl_cffi.requests.Response with properties from this class (type cast of the curl_cffi response).

```
response = typing.cast(SXNG_Response, response)
if response.ok:
   ...
query_was = search_params["query"]
```

html() → [HtmlElement](https://lxml.de/apidoc/lxml.html.html#lxml.html.HtmlElement)[[source]](https://docs.searxng.org/_modules/searx/extended_types.html#SXNG_Response.html)
:   Parses the result into a HTML document via [`lxml.html`](https://lxml.de/apidoc/lxml.html.html#module-lxml.html).

Copyright © SearXNG team

Made with Furo

💾 🌐