diff --git a/Code/Austen/working/flask-02/app.py b/Code/Austen/working/flask-02/app.py new file mode 100644 index 00000000..7ccda8e5 --- /dev/null +++ b/Code/Austen/working/flask-02/app.py @@ -0,0 +1,34 @@ +from flask import Flask, request +from flask import render_template as render +from string import ascii_lowercase, ascii_uppercase, punctuation, digits +from random import randint + + +app = Flask(__name__) + +@app.route('/', methods=['GET', 'POST']) +def index(): + charsets = ['lower case', 'upper case', 'special characters', 'digits'] + strings = {'lower case': ascii_lowercase, 'upper case': ascii_uppercase, 'special characters': punctuation, 'digits': digits} + if request.method == 'POST': + charsets = request.form + charset = [] + password = [] + for key in charsets.keys(): + count = int(charsets[key]) + if count > 0: + set = strings[key] + for i in range(count): + index = randint(0, len(set) - 1) + char = set[index] + charset.append(char) + while len(charset) > 0: + index = randint(0, len(charset) - 1) + char = charset.pop(index) + password.append(char) + password = ''.join(password) + + + + return render('password.html', charset=charset, password=password) + return render('index.html', charsets=charsets) diff --git a/Code/Austen/working/flask-02/static/signature.css b/Code/Austen/working/flask-02/static/signature.css new file mode 100644 index 00000000..af15e550 --- /dev/null +++ b/Code/Austen/working/flask-02/static/signature.css @@ -0,0 +1,19 @@ +body { + color: white; + font-family: consolas; + background-color: black; + text-align: center; +} +form { + text-align: right; + margin: 5rem; + border: 1px solid white; + padding: 20px; +} + +input { + width: 50px; +} +a:any-link { + color: red; +} diff --git a/Code/Austen/working/flask-02/templates/base.html b/Code/Austen/working/flask-02/templates/base.html new file mode 100644 index 00000000..5b0ec5be --- /dev/null +++ b/Code/Austen/working/flask-02/templates/base.html @@ -0,0 +1,13 @@ + + + + + + + Password Generator + + + +
{% block content %} {% endblock %}
+ + diff --git a/Code/Austen/working/flask-02/templates/index.html b/Code/Austen/working/flask-02/templates/index.html new file mode 100644 index 00000000..08081dc8 --- /dev/null +++ b/Code/Austen/working/flask-02/templates/index.html @@ -0,0 +1,20 @@ +{% extends 'base.html' %} {% block content %} + +
+

PassGen

+

your source for passwords you'll never remember

+
(or even where you saved them)
+
+
+
+ {% for set in charsets %} + +
+ {% endfor %} + +
+
+ +{% endblock %} diff --git a/Code/Austen/working/flask-02/templates/password.html b/Code/Austen/working/flask-02/templates/password.html new file mode 100644 index 00000000..e0950e44 --- /dev/null +++ b/Code/Austen/working/flask-02/templates/password.html @@ -0,0 +1,6 @@ +{% extends 'index.html' %} {% block content %} + +

your password is:

+

{{password}}

+start over +{% endblock %}