start project

This commit is contained in:
Hemmat
2026-08-07 21:17:17 +03:30
commit ea1e1eead6
121 changed files with 8108 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
"""Shared page/per_page parsing (Chapter 11: consistent across every
Grid.js-backed endpoint)."""
from __future__ import annotations
from flask import Request
DEFAULT_PER_PAGE = 20
MAX_PER_PAGE = 100
def parse_pagination(request: Request) -> tuple[int, int]:
page = max(1, request.args.get("page", 1, type=int))
per_page = request.args.get("per_page", DEFAULT_PER_PAGE, type=int)
return page, max(1, min(per_page, MAX_PER_PAGE))