.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
http_accept.py
Go to the documentation of this file.
1
# SPDX-License-Identifier: AGPL-3.0-or-later
2
"""
3
Method ``http_accept``
4
----------------------
5
6
The ``http_accept`` method evaluates a request as the request of a bot if the
7
Accept_ header ..
8
9
- did not contain ``text/html``
10
11
.. _Accept:
12
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
13
14
"""
15
# pylint: disable=unused-argument
16
17
from
__future__
import
annotations
18
from
ipaddress
import
(
19
IPv4Network,
20
IPv6Network,
21
)
22
23
import
flask
24
import
werkzeug
25
26
from
.
import
config
27
from
._helpers
import
too_many_requests
28
29
30
def
filter_request
(
31
network: IPv4Network | IPv6Network,
32
request: flask.Request,
33
cfg:
config.Config
,
34
) -> werkzeug.Response |
None
:
35
36
if
'text/html'
not
in
request.accept_mimetypes:
37
return
too_many_requests(network,
"HTTP header Accept did not contain text/html"
)
38
return
None
searx.botdetection.config.Config
Definition
config.py:54
searx.botdetection.http_accept.filter_request
werkzeug.Response|None filter_request(IPv4Network|IPv6Network network, flask.Request request, config.Config cfg)
Definition
http_accept.py:34
searxng
searx
botdetection
http_accept.py
Generated on Sat Nov 16 2024 00:10:57 for .oO SearXNG Developer Documentation Oo. by
1.12.0