|
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= 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 |
|
|
|
|