You can download this code by clicking the button below.
This code is now available for download.
This function generates a list of random numbers within a specified range and returns it in JSON format.
Technology Stack : Starlette, random, randint
Code Type : API Function
Code Difficulty : Intermediate
def random_number_generator(min_value, max_value, num_count):
from random import randint
from starlette.responses import JSONResponse
numbers = [randint(min_value, max_value) for _ in range(num_count)]
return JSONResponse(numbers)