import random from urllib.parse import urlencode from twisted.web.server import Site from twisted.web.resource import Resource class Root(Resource): isLeaf = True def getChild(self, name, request): return self def render(self, request): total = _getarg(request, b'total', 100, int) show = _getarg(request, b'show', 10, int) nlist = [random.randint(1, total) for _ in range(show)] request.write(b"
") args = request.args.copy() for nl in nlist: args['n'] = nl argstr = urlencode(args, doseq=True) request.write(f"follow {nl}