I am working with CherryPy framework. I am implementing REST and what i want the HTTP Method GET to retrieve some information given a parameter passed in the URL that should be an integer. This parameter is optional and if not given it must be set by default to 10. In the CherryPy docs (https://docs.cherrypy.dev/en/latest/advanced.html) i found this piece of code in which where a default value for the variable length is set.
import random
import string
import cherrypy
class StringGenerator(object):
@cherrypy.expose(['generer', 'generar'])
def generate(self, length=8):
return ''.join(random.sample(string.hexdigits, int(length)))
if __name__ == '__main__':
cherrypy.quickstart(StringGenerator())
How can i do the same for GET?