kremle-detect 2.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,68 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ kremle-detect — защита сайта от пользователей Яндекс Браузера.
4
+
5
+ Фреймворк-агностичное ядро + интеграции для Flask, Django, FastAPI.
6
+
7
+ Быстрый старт (Flask):
8
+ from kremle_detect.integrations.flask_ext import KremleFlask
9
+ kremle = KremleFlask(app, categories=['math', 'physics'])
10
+
11
+ Быстрый старт (Django):
12
+ # settings.py → MIDDLEWARE += ['kremle_detect.integrations.django_ext.KremleDjangoMiddleware']
13
+ # urls.py → path('kremle/', kremle_urls())
14
+
15
+ Быстрый старт (FastAPI):
16
+ from kremle_detect.integrations.fastapi_ext import KremleFastAPI
17
+ kremle = KremleFastAPI(app, secret='...')
18
+
19
+ Использование ядра напрямую (любой фреймворк):
20
+ from kremle_detect import detect, CaptchaEngine
21
+
22
+ # Детекция
23
+ result = detect({'User-Agent': '...', 'Referer': '...'})
24
+ if result:
25
+ print(result.reason)
26
+
27
+ # Капча с Redis
28
+ from kremle_detect import RedisStorage
29
+ engine = CaptchaEngine(storage=RedisStorage(url='redis://localhost:6379/0'))
30
+ """
31
+
32
+ __version__ = '2.7.0'
33
+
34
+ from .detector import (
35
+ detect,
36
+ detect_from_request,
37
+ DetectResult,
38
+ is_yandex_browser,
39
+ is_yandex_bot,
40
+ is_yandex_referrer,
41
+ is_yandex_client_hints,
42
+ )
43
+ from .captcha import CaptchaEngine, Challenge
44
+ from .questions import get_questions, validate_questions, ALL_CATEGORY_NAMES, CATEGORIES
45
+ from .storage import BaseStorage, MemoryStorage, RedisStorage
46
+
47
+ __all__ = [
48
+ # Детекция
49
+ 'detect',
50
+ 'detect_from_request',
51
+ 'DetectResult',
52
+ 'is_yandex_browser',
53
+ 'is_yandex_bot',
54
+ 'is_yandex_referrer',
55
+ 'is_yandex_client_hints',
56
+ # Капча
57
+ 'CaptchaEngine',
58
+ 'Challenge',
59
+ # Вопросы
60
+ 'get_questions',
61
+ 'validate_questions',
62
+ 'ALL_CATEGORY_NAMES',
63
+ 'CATEGORIES',
64
+ # Хранилище
65
+ 'BaseStorage',
66
+ 'MemoryStorage',
67
+ 'RedisStorage',
68
+ ]