Created
September 4, 2020 14:48
-
-
Save jslvtr/af13be72a8f459c641f3cd3bdbf97221 to your computer and use it in GitHub Desktop.
Complete code for our "Dynamic Web Pages" YouTube video under our Flask Tutorial for Beginners series: https://youtu.be/CHRikEvvcUc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, request | |
app = Flask(__name__) | |
transactions = [] | |
@app.route("/", methods=["GET", "POST"]) | |
def home(): | |
print(request.form) | |
return render_template("form.html") | |
@app.route("/transactions") | |
def transactions(): | |
return render_template("transactions.html", transactions=transactions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Personal finance</title> | |
<link rel="stylesheet" href="/static/style.css" /> | |
</head> | |
<body> | |
<h1>Add transaction</h1> | |
<form method="POST"> | |
<div class="form__fieldset"> | |
<label for="date" class="form__label">Date:</label> | |
<input type="date" name="date" id="date" class="form__input" /> | |
</div> | |
<div class="form__fieldset"> | |
<label for="amount" class="form__label">Amount:</label> | |
<input type="number" name="amount" id="amount" class="form__input" /> | |
</div> | |
<div class="form__fieldset"> | |
<label for="account" class="form__label">Account:</label> | |
<select name="account" id="account" class="form__input form__select"> | |
<option value="Checking">Checking</option> | |
<option value="Savings">Savings</option> | |
<option value="Investment">Investment</option> | |
</select> | |
</div> | |
<div class="form__fieldset"> | |
<input | |
class="form__submit form__input" | |
type="submit" | |
value="Add transaction" | |
/> | |
</div> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
font-size: 17px; | |
font-family: "Segoe UI", Arial, Helvetica, sans-serif; | |
} | |
body { | |
max-width: 1000px; | |
margin: 0 auto; | |
padding: 20px; | |
} | |
.form__fieldset { | |
padding: 40px 20px; | |
} | |
.form__fieldset:not(:last-of-type) { | |
border-bottom: 1px solid rgba(0, 0, 0, 0.1); | |
} | |
.form__input { | |
font-size: 1rem; | |
} | |
.form__select { | |
padding: 4px 2px; | |
} | |
.form__label { | |
margin-right: 20px; | |
} | |
.form__submit { | |
padding: 8px 16px; | |
background-color: unset; | |
border: 2px solid #1c2023; | |
border-radius: 4px; | |
cursor: pointer; | |
float: right; | |
} | |
.form__submit:hover { | |
background-color: #1c2023; | |
color: white; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not the new code from the fourth video☹️