Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Code/Austen/working/flask-02/app.py
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions Code/Austen/working/flask-02/static/signature.css
Original file line number Diff line number Diff line change
@@ -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;
}
13 changes: 13 additions & 0 deletions Code/Austen/working/flask-02/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Password Generator</title>
<link rel="stylesheet" href="{{url_for('static', filename='signature.css')}}">
</head>
<body>
<div>{% block content %} {% endblock %}</div>
</body>
</html>
20 changes: 20 additions & 0 deletions Code/Austen/working/flask-02/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'base.html' %} {% block content %}

<header>
<h1>PassGen</h1>
<h4>your source for passwords you'll never remember</h4>
<h5>(or even where you saved them)</h5>
</header>
<main>
<form method="post">
{% for set in charsets %}
<label for="{{set}}">{{set}}
<input type="number" name="{{set}}" value="0">
</label>
<br>
{% endfor %}
<button type="submit">go</button>
</form>
</main>

{% endblock %}
6 changes: 6 additions & 0 deletions Code/Austen/working/flask-02/templates/password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends 'index.html' %} {% block content %}

<h1>your password is:</h1>
<h2>{{password}}</h2>
<a href="/">start over</a>
{% endblock %}