MCPcopy
hub / github.com/scrapy/scrapy / render

Method render

scrapy/utils/benchserver.py:15–27  ·  view source on GitHub ↗
(self, request: Request)

Source from the content-addressed store, hash-verified

13 return self
14
15 def render(self, request: Request) -> bytes:
16 total = _getarg(request, b"total", 100, int)
17 show = _getarg(request, b"show", 10, int)
18 nlist = [random.randint(1, total) for _ in range(show)] # noqa: S311
19 request.write(b"<html><head></head><body>")
20 assert request.args is not None
21 args = request.args.copy()
22 for nl in nlist:
23 args["n"] = nl
24 argstr = urlencode(args, doseq=True)
25 request.write(f"<a href='/follow?{argstr}'>follow {nl}</a><br>".encode())
26 request.write(b"</body></html>")
27 return b""
28
29
30def _getarg(

Callers

nothing calls this directly

Calls 3

_getargFunction · 0.85
writeMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected