Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Created February 1, 2016 05:09
Show Gist options
  • Save gnilchee/184435cd3f23df8cdf0a to your computer and use it in GitHub Desktop.
Save gnilchee/184435cd3f23df8cdf0a to your computer and use it in GitHub Desktop.
Simple Password Generator via Cherrypy
#!/usr/bin/env python3
import random
import string
import cherrypy
class PasswordGenerator(object):
@cherrypy.expose
def index(self):
return '''
<html>
<title>Password Generator</title>
<body>
<center><h1>Password Generator</h1></center>
<center><h2>To start generating click <a href="generate">here</a></h2></center>
</body>
</html>
'''
@cherrypy.expose
def generate(self, length=16):
return ''.join(random.sample(string.printable, int(length)))
cherrypy.config.update({'server.socket_host': '0.0.0.0',
'server.socket_port': 8080,
'engine.autoreload_on': False})
if __name__ == '__main__':
cherrypy.quickstart(PasswordGenerator())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment