From f77204acfb2ec03871cfad400e80dcf2c815a2c8 Mon Sep 17 00:00:00 2001 From: "Austen C. Myers-Flachson" Date: Thu, 30 Dec 2021 17:38:42 -0700 Subject: [PATCH 1/3] init flask app --- Code/Austen/working/flask-02/app.py | 1 + Code/Austen/working/flask-02/templates/base.html | 0 Code/Austen/working/flask-02/templates/index.html | 0 3 files changed, 1 insertion(+) create mode 100644 Code/Austen/working/flask-02/app.py create mode 100644 Code/Austen/working/flask-02/templates/base.html create mode 100644 Code/Austen/working/flask-02/templates/index.html diff --git a/Code/Austen/working/flask-02/app.py b/Code/Austen/working/flask-02/app.py new file mode 100644 index 00000000..5a03df9c --- /dev/null +++ b/Code/Austen/working/flask-02/app.py @@ -0,0 +1 @@ +from flask import Flask 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..e69de29b 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..e69de29b From 7189da6079b23ad0be50554a9eed398301e3287d Mon Sep 17 00:00:00 2001 From: "Austen C. Myers-Flachson" Date: Thu, 30 Dec 2021 18:13:45 -0700 Subject: [PATCH 2/3] commit to switch branch --- Code/Austen/working/flask-02/app.py | 12 +++++++++++- .../working/flask-02/static/signature.css | 4 ++++ .../working/flask-02/templates/base.html | 13 +++++++++++++ .../working/flask-02/templates/index.html | 19 +++++++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 Code/Austen/working/flask-02/static/signature.css diff --git a/Code/Austen/working/flask-02/app.py b/Code/Austen/working/flask-02/app.py index 5a03df9c..d21405a4 100644 --- a/Code/Austen/working/flask-02/app.py +++ b/Code/Austen/working/flask-02/app.py @@ -1 +1,11 @@ -from flask import Flask +from flask import Flask, request +from flask import render_template as render +from string import ascii_lowercase, ascii_uppercase, punctuation, digits + + +app = Flask(__name__) + +@app.route('/') +def index(): + charsets = ['lower case', 'upper case', 'special characters', 'digits'] + 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..a87248cf --- /dev/null +++ b/Code/Austen/working/flask-02/static/signature.css @@ -0,0 +1,4 @@ +body { + color: white; + background-color: black; +} diff --git a/Code/Austen/working/flask-02/templates/base.html b/Code/Austen/working/flask-02/templates/base.html index e69de29b..5b0ec5be 100644 --- a/Code/Austen/working/flask-02/templates/base.html +++ 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 index e69de29b..e387eb8a 100644 --- a/Code/Austen/working/flask-02/templates/index.html +++ b/Code/Austen/working/flask-02/templates/index.html @@ -0,0 +1,19 @@ +{% 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 %} From 23a1306a64395107e72d33ca1593b3698573a8ed Mon Sep 17 00:00:00 2001 From: "Austen C. Myers-Flachson" Date: Thu, 30 Dec 2021 19:12:54 -0700 Subject: [PATCH 3/3] it sucks but it works --- Code/Austen/working/flask-02/app.py | 29 +++++++++++++++++-- .../working/flask-02/static/signature.css | 15 ++++++++++ .../working/flask-02/templates/index.html | 7 +++-- .../working/flask-02/templates/password.html | 6 ++++ 4 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 Code/Austen/working/flask-02/templates/password.html diff --git a/Code/Austen/working/flask-02/app.py b/Code/Austen/working/flask-02/app.py index d21405a4..7ccda8e5 100644 --- a/Code/Austen/working/flask-02/app.py +++ b/Code/Austen/working/flask-02/app.py @@ -1,11 +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('/') +@app.route('/', methods=['GET', 'POST']) def index(): - charsets = ['lower case', 'upper case', 'special characters', 'digits'] - return render('index.html', charsets=charsets) + 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 index a87248cf..af15e550 100644 --- a/Code/Austen/working/flask-02/static/signature.css +++ b/Code/Austen/working/flask-02/static/signature.css @@ -1,4 +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/index.html b/Code/Austen/working/flask-02/templates/index.html index e387eb8a..08081dc8 100644 --- a/Code/Austen/working/flask-02/templates/index.html +++ b/Code/Austen/working/flask-02/templates/index.html @@ -6,13 +6,14 @@

your source for passwords you'll never remember

(or even where you saved them)
-
+ {% for set in charsets %} +
{% endfor %} - +
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 %}