首页 > 其他 > 详细

cherrypy 表单提交

时间:2020-12-23 17:00:53      阅读:48      评论:0      收藏:0      [点我收藏+]

code

import random
import string
import cherrypy

class StringGenerator(object):
    @cherrypy.expose
    def index(self):
        return """<html>
          <head></head>
          <body>
            <form method="get" action="generate">
              <input type="text" value="8" name="length" />
              <button type="submit">Give it now!</button>
            </form>
          </body>
        </html>"""

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


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

 

 

 

 

 

cherrypy 表单提交

原文:https://www.cnblogs.com/sea-stream/p/14179089.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!