-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (22 loc) · 799 Bytes
/
app.py
File metadata and controls
31 lines (22 loc) · 799 Bytes
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, render_template, request, redirect, url_for
from flask_bootstrap import Bootstrap
app = Flask(__name__)
Bootstrap(app)
def generate_random_password(length):
import random
import string
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random.choice(characters) for _ in range(length))
return password
@app.route('/')
def index():
return render_template('index.html')
@app.route('/generate_password', methods=['GET', 'POST'])
def generate_password():
password = None
if request.method == 'POST':
length = int(request.form['length'])
password = generate_random_password(length)
return render_template('index.html', password=password)
if __name__ == "__main__":
app.run()