cherrypy 给URL传默认参数

code

import random
import string
import cherrypy

class StringGenerator(object):
    @cherrypy.expose
    def index(self):
        return "Hello world!"

    @cherrypy.expose
    def generate(self, length=8):
        return ''.join(random.sample(string.hexdigits, int(length)))

if __name__ == '__main__':
    cherrypy.quickstart(StringGenerator())

 

 

 

 

 

 

 

 

posted @ 2020-12-23 15:51  anobscureretreat  阅读(140)  评论(0编辑  收藏  举报