.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
8
Plugins can extend or replace functionality of various components of SearXNG.
9
Here is an example of a very simple plugin that adds a "Hello" into the answer
10
area:
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
30
Entry points (hooks) define when a plugin runs. Right now only three hooks are
31
implemented. So feel free to implement a hook if it fits the behaviour of your
32
plugin / 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
38
For 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
57
from
__future__
import
annotations
58
59
__all__ = [
"PluginInfo"
,
"Plugin"
,
"PluginStorage"
]
60
61
from
._core
import
PluginInfo, Plugin, PluginStorage
62
63
STORAGE: PluginStorage =
PluginStorage
()
64
65
66
def
initialize
(app):
67
STORAGE.load_builtins()
68
STORAGE.init(app)
searx.plugins._core.PluginStorage
Definition
_core.py:236
searx.plugins.initialize
initialize(app)
Definition
__init__.py:66
searxng
searx
plugins
__init__.py
Generated on Thu Feb 20 2025 20:12:42 for .oO SearXNG Developer Documentation Oo. by
1.13.2