REST API for random number generation using Falcon I have written REST API for random number generation using Falcon(https://falconframework.org/), just for my learning process. 

This is API:

http "localhost:8000/random-number?min=10&amp;max=10"


This is code:

class RandomNumber:
    def on_get(self, req, resp):
        """Handles GET requests"""

        if 'min' not in req.params:
            raise falcon.HTTPMissingParam('min')

        if 'max' not in req.params:
            raise falcon.HTTPMissingParam('max')

        min_n = req.params['min']
        max_n = req.params['max']

        if min_n.isnumeric() == False:
            raise falcon.HTTPInvalidParam('min must be number', min_n)

        if max_n.isnumeric() == False:
            raise falcon.HTTPInvalidParam('max must be number', max_n)

        min_n =int(min_n)
        max_n =int(max_n)

        if min_n &gt; max_n:
            raise falcon.HTTPInvalidParam('min is bigger than max', (min_n, max_n))

        number = random.randint(min_n, max_n)
        result = {'lowerLimit': min_n, 'higherLimit': max_n, 'number': number}
        resp.media = result

api = falcon.API()
api.add_route('/random-number', RandomNumber())


Feedback appreciated.
This is a small code, but there are some improvements to make:


useless copy-paste, what if you had 5 conditions?:

if 'min' not in req.params:
    raise falcon.HTTPMissingParam('min')

if 'max' not in req.params:
    raise falcon.HTTPMissingParam('max')



when you can do:

for c in ['min','max']:
  if c not in req.params:
      raise falcon.HTTPMissingParam(c)



don't test with == False

if min_n.isnumeric() ==  False:



should be

    if not min_n.isnumeric():