File size: 789 Bytes
8e34c2b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
from flask import Flask, request, render_template
from markupsafe import Markup
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def index():
if request.method == 'POST':
# opt= passgenm(request.form['len'], request.form['num'])
opt= passgen(request.form['len'])
return render_template('result.html', result=Markup(opt))
else:
return render_template('index.html')
def passgenm(length,number):
opt=""
for i in range(int(number)):
opt+=passgen(length)+"<br>\n"
return opt
def passgen(length):
import random
import string
length = int(length)
password = ''
for i in range(length):
password += random.choice(string.ascii_letters + string.digits + string.punctuation)
return password
|