Routing and static file serving.
最初に以下の最小例でモジュール利用方法を確認し、その後 API リファレンスを参照してください。
from nexom.app.path import Get, Router
from nexom.app.response import HtmlResponse
def top(request, args):
return HtmlResponse('<h1>Top</h1>')
def docs(request, args):
page = args.get('page')
return HtmlResponse(f'<h1>{page}</h1>')
routing = Router(
Get('', top, 'Top'),
Get('documents/{page}', docs, 'Docs'),
)
分類: public class
Represents a route with optional path arguments and its handler.
分類: special method
__init__(self, path: str, handler: Handler, name: str, *, methods: set[str] | None = None)
メソッドドキュメントは未定義です。
path / kind=positional-or-keyword / type=str / 必須 / default=なしhandler / kind=positional-or-keyword / type=Handler / 必須 / default=なしname / kind=positional-or-keyword / type=str / 必須 / default=なしmethods / kind=keyword-only / type=set[str] | None / 任意 / default=None型指定なし
実装コード内の例外仕様を確認してください。
from nexom.app.path import Path
obj = Path(path="sample", handler=..., name="sample", methods=None)
分類: internal method
_read_args(self, request_path: str) -> dict[str, Optional[str] | list[str]]
Build args for this request (no shared state).
request_path / kind=positional-or-keyword / type=str / 必須 / default=なしdict[str, Optional[str] | list[str]]
実装コード内の例外仕様を確認してください。
from nexom.app.path import Path
obj = Path(...)
result = obj._read_args(request_path="sample")
print(result)
分類: public method
match(self, request_path: str) -> tuple[bool, int]
Return whether request_path matches this path and static match count.
request_path / kind=positional-or-keyword / type=str / 必須 / default=なしtuple[bool, int]
実装コード内の例外仕様を確認してください。
from nexom.app.path import Path
obj = Path(...)
result = obj.match(request_path="sample")
print(result)
分類: public method
call_handler(self, request: Request, middlewares: tuple[Middleware, ...] = ()) -> Response
Execute the handler (and middlewares) and normalize the result.
request / kind=positional-or-keyword / type=Request / 必須 / default=なしmiddlewares / kind=positional-or-keyword / type=tuple[Middleware, ...] / 任意 / default=()Response
実装コード内の例外仕様を確認してください。
from nexom.app.path import Path
obj = Path(...)
result = obj.call_handler(request=..., middlewares=())
print(result)
分類: public class
GET-only route.
分類: special method
__init__(self, path: str, handler: Handler, name: str)
メソッドドキュメントは未定義です。
path / kind=positional-or-keyword / type=str / 必須 / default=なしhandler / kind=positional-or-keyword / type=Handler / 必須 / default=なしname / kind=positional-or-keyword / type=str / 必須 / default=なし型指定なし
実装コード内の例外仕様を確認してください。
from nexom.app.path import Get
obj = Get(path="sample", handler=..., name="sample")
分類: public class
POST-only route (plus OPTIONS for preflight).
分類: special method
__init__(self, path: str, handler: Handler, name: str)
メソッドドキュメントは未定義です。
path / kind=positional-or-keyword / type=str / 必須 / default=なしhandler / kind=positional-or-keyword / type=Handler / 必須 / default=なしname / kind=positional-or-keyword / type=str / 必須 / default=なし型指定なし
実装コード内の例外仕様を確認してください。
from nexom.app.path import Post
obj = Post(path="sample", handler=..., name="sample")
分類: public class
Represents a static file route.
分類: special method
__init__(self, path: str, static_directory: str, name: str) -> None
メソッドドキュメントは未定義です。
path / kind=positional-or-keyword / type=str / 必須 / default=なしstatic_directory / kind=positional-or-keyword / type=str / 必須 / default=なしname / kind=positional-or-keyword / type=str / 必須 / default=なしNone
実装コード内の例外仕様を確認してください。
from nexom.app.path import Static
obj = Static(path="sample", static_directory="sample", name="sample")
分類: internal method
_access(self, request: Request, args: dict[str, Optional[str] | list[str]]) -> Response
Serve a static file from the configured root.
request / kind=positional-or-keyword / type=Request / 必須 / default=なしargs / kind=positional-or-keyword / type=dict[str, Optional[str] | list[str]] / 必須 / default=なしResponse
実装コード内の例外仕様を確認してください。
from nexom.app.path import Static
obj = Static(...)
result = obj._access(request=..., args="sample")
print(result)
分類: public class
Collection of Path objects with middleware support.
分類: special method
__init__(self, *paths: Path) -> None
メソッドドキュメントは未定義です。
paths / kind=variadic-positional(*args) / type=Path / 必須 / default=なしNone
実装コード内の例外仕様を確認してください。
from nexom.app.path import Router
obj = Router()
分類: internal method
_check(self, arg: object) -> None
メソッドドキュメントは未定義です。
arg / kind=positional-or-keyword / type=object / 必須 / default=なしNone
実装コード内の例外仕様を確認してください。
from nexom.app.path import Router
obj = Router(...)
result = obj._check(arg=...)
print(result)
分類: public method
add_middleware(self, *middlewares: Middleware) -> None
Register middleware(s) for this router.
middlewares / kind=variadic-positional(*args) / type=Middleware / 必須 / default=なしNone
実装コード内の例外仕様を確認してください。
from nexom.app.path import Router
obj = Router(...)
result = obj.add_middleware()
print(result)
分類: public method
get(self, request_path: str, *, method: str | None = None) -> Path | None
Resolve a Path for a request path and method. Returns None if not found and raise_if_not_exist is False.
request_path / kind=positional-or-keyword / type=str / 必須 / default=なしmethod / kind=keyword-only / type=str | None / 任意 / default=NonePath | None
実装コード内の例外仕様を確認してください。
from nexom.app.path import Router
obj = Router(...)
result = obj.get(request_path="sample", method=None)
print(result)
分類: public method
handle(self, request: Request) -> Response
Resolve and execute a route for the given request.
request / kind=positional-or-keyword / type=Request / 必須 / default=なしResponse
実装コード内の例外仕様を確認してください。
from nexom.app.path import Router
obj = Router(...)
result = obj.handle(request=...)
print(result)
nexom.app.pathservices/venv/lib/python3.10/site-packages/nexom/app/path.py2026-03-14