.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1# SPDX-License-Identifier: AGPL-3.0-or-later
2""".. sidebar:: Further reading ..
3
4 - :ref:`plugins admin`
5 - :ref:`SearXNG settings <settings plugins>`
6 - :ref:`builtin plugins`
7
8Plugins can extend or replace functionality of various components of SearXNG.
9Here is an example of a very simple plugin that adds a "Hello" into the answer
10area:
11
12.. code:: python
13
14 from flask_babel import gettext as _
15 from searx.plugins import Plugin
16 from searx.result_types import Answer
17
18 class MyPlugin(Plugin):
19
20 id = "self_info"
21 default_on = True
22
23 def __init__(self):
24 super().__init__()
25 info = PluginInfo(id=self.id, name=_("Hello"), description=_("demo plugin"))
26
27 def post_search(self, request, search):
28 return [ Answer(answer="Hello") ]
29
30Entry points (hooks) define when a plugin runs. Right now only three hooks are
31implemented. So feel free to implement a hook if it fits the behaviour of your
32plugin / a plugin doesn't need to implement all the hooks.
33
34- pre search: :py:obj:`Plugin.pre_search`
35- post search: :py:obj:`Plugin.post_search`
36- on each result item: :py:obj:`Plugin.on_result`
37
38For a coding example have a look at :ref:`self_info plugin`.
39
40----
41
42.. autoclass:: Plugin
43 :members:
44
45.. autoclass:: PluginInfo
46 :members:
47
48.. autoclass:: PluginStorage
49 :members:
50
51.. autoclass:: searx.plugins._core.ModulePlugin
52 :members:
53 :show-inheritance:
54
55"""
56
57from __future__ import annotations
58
59__all__ = ["PluginInfo", "Plugin", "PluginStorage"]
60
61from ._core import PluginInfo, Plugin, PluginStorage
62
63STORAGE: PluginStorage = PluginStorage()
64
65
66def initialize(app):
67 STORAGE.load_builtins()
68 STORAGE.init(app)
initialize(app)
Definition __init__.py:66