@app.route("<STR_LIT>")<EOL>def range_request(numbytes):
if numbytes <= <NUM_LIT:0> or numbytes > (<NUM_LIT:100> * <NUM_LIT>):<EOL><INDENT>response = Response(<EOL>headers={"<STR_LIT>": "<STR_LIT>" % numbytes, "<STR_LIT>": "<STR_LIT>"}<EOL>)<EOL>response.status_code = <NUM_LIT><EOL>response.data = "<STR_LIT>"<EOL>return response<EOL><DEDENT>params = CaseInsensitiveDict(request.args.items())<EOL>if "<STR_LIT>" in params:<EOL><INDENT>chunk_size = max(<NUM_LIT:1>, int(params["<STR_LIT>"]))<EOL><DEDENT>else:<EOL><INDENT>chunk_size = <NUM_LIT:10> * <NUM_LIT><EOL><DEDENT>duration = float(params.get("<STR_LIT>", <NUM_LIT:0>))<EOL>pause_per_byte = duration / numbytes<EOL>request_headers = get_headers()<EOL>first_byte_pos, last_byte_pos = get_request_range(request_headers, numbytes)<EOL>range_length = (last_byte_pos + <NUM_LIT:1>) - first_byte_pos<EOL>if (<EOL>first_byte_pos > last_byte_pos<EOL>or first_byte_pos not in xrange(<NUM_LIT:0>, numbytes)<EOL>or last_byte_pos not in xrange(<NUM_LIT:0>, numbytes)<EOL>):<EOL><INDENT>response = Response(<EOL>headers={<EOL>"<STR_LIT>": "<STR_LIT>" % numbytes,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>" % numbytes,<EOL>"<STR_LIT>": "<STR_LIT:0>",<EOL>}<EOL>)<EOL>response.status_code = <NUM_LIT><EOL>return response<EOL><DEDENT>def generate_bytes():<EOL><INDENT>chunks = bytearray()<EOL>for i in xrange(first_byte_pos, last_byte_pos + <NUM_LIT:1>):<EOL><INDENT>chunks.append(ord("<STR_LIT:a>") + (i % <NUM_LIT>))<EOL>if len(chunks) == chunk_size:<EOL><INDENT>yield (bytes(chunks))<EOL>time.sleep(pause_per_byte * chunk_size)<EOL>chunks = bytearray()<EOL><DEDENT><DEDENT>if chunks:<EOL><INDENT>time.sleep(pause_per_byte * len(chunks))<EOL>yield (bytes(chunks))<EOL><DEDENT><DEDENT>content_range = "<STR_LIT>" % (first_byte_pos, last_byte_pos, numbytes)<EOL>response_headers = {<EOL>"<STR_LIT:Content-Type>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>" % numbytes,<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": str(range_length),<EOL>"<STR_LIT>": content_range,<EOL>}<EOL>response = Response(generate_bytes(), headers=response_headers)<EOL>if (first_byte_pos == <NUM_LIT:0>) and (last_byte_pos == (numbytes - <NUM_LIT:1>)):<EOL><INDENT>response.status_code = <NUM_LIT:200><EOL><DEDENT>else:<EOL><INDENT>response.status_code = <NUM_LIT><EOL><DEDENT>return response<EOL>
Streams n random bytes generated with given seed, at given chunk size per packet.
    ---
    tags:
      - Dynamic data
    parameters:
      - in: path
        name: numbytes
        type: int
    produces:
      - application/octet-stream
    responses:
      200:
        description: Bytes.