ЛР 3 — БПИ2303 — Унру — на 3

This commit is contained in:
2026-11-13 01:17:53 +03:00
parent ec540a1a72
commit 69f09f30c9
65 changed files with 5020 additions and 33 deletions
+19
View File
@@ -0,0 +1,19 @@
class ApiError(Exception):
def __init__(self, status, code, message, headers=None):
self.status = status
self.code = code
self.message = message
self.headers = headers or {}
def invalid():
return ApiError(400, 'invalid_request', 'Неверный запрос')
def unauthorized(basic=False):
scheme = 'Basic realm="messenger", charset="UTF-8"' if basic else 'Bearer realm="messenger"'
return ApiError(401, 'unauthorized', 'Требуется аутентификация', {'WWW-Authenticate': scheme})
def not_found():
return ApiError(404, 'not_found', 'Объект не найден')