GenPass
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import string
from random import choice
from webob import Request, Response
def GenPass(length):
return ''.join([choice(string.letters + string.digits) for i in range(int(length))])
def GenPassWeb(environ, start_response):
r = Request(environ)
l = r.GET['length']
response = Response(content_type='text/plain', body=GenPass(l))
return response(environ, start_response)
def main():
from paste.httpserver import serve
serve (GenPassWeb)
if __name__ == "__main__":
main()
|