passgen / app.py
sca255's picture
v1 complete
5a32cac unverified
raw
history blame
789 Bytes
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