From c21e8b36b7e351309041b4a6430d5efe176bcf37 Mon Sep 17 00:00:00 2001 From: James Turk Date: Sat, 22 May 2021 15:23:17 -0400 Subject: [PATCH] add staff page --- app.py | 10 ++++++++++ data/employees.csv | 46 ++++++++++++++++++++++++++++++++++++++++++++ templates/base.html | 1 + templates/staff.html | 31 +++++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 data/employees.csv create mode 100644 templates/staff.html diff --git a/app.py b/app.py index ea97d60..53d725f 100644 --- a/app.py +++ b/app.py @@ -1,3 +1,4 @@ +import csv from flask import Flask, render_template app = Flask(__name__) @@ -11,3 +12,12 @@ def index(): @app.route("/about") def about(): return render_template("about.html") + + +@app.route("/staff") +def staff(): + # thanks to http://www.figmentfly.com/bb/badguys3.html for names + with open("data/employees.csv") as f: + employees = list(csv.DictReader(f)) + + return render_template("staff.html", employees=employees) diff --git a/data/employees.csv b/data/employees.csv new file mode 100644 index 0000000..4b9154b --- /dev/null +++ b/data/employees.csv @@ -0,0 +1,46 @@ +first,last,position,status,children,hired +John,Barnett,Scheduling,Married,1,3/6/1963 +John,Bigbooté,Executive Vice President,Single,0,10/31/1938 +John,Camp,Human Resources,Single,0,6/12/1985 +John,Careful Walker,Accounting,Single,0,4/30/1990 +John,Chief Crier,"VP, Public Relations",Married,2,4/2/1980 +John,Cooper,Storage Acquisition,Single,0,8/15/1984 +John,Coyote,Medical Research,Married,6,1/1/1970 +John,Edwards,Public Relations,Divorced,2,8/15/1984 +John,Fat Eating,Craft Services,Single,0,8/15/1984 +John,Fish,Marine R&D,Divorced,12,10/31/1938 +John,Fledgling,Human Resources,Married,2,7/4/1976 +John,Gomez,"VP, Sales",Married,1,8/15/1984 +John,Grim,Actuary,Married,1.8,9/9/1970 +John,Guardian,Optical Systems Engineer,Single,0,6/9/1980 +John,Icicle Boy,Refrigeration R&D,Single,0,2/6/1939 +John,Jones,Government Relations,Married,3,8/15/1984 +John,Joseph,Government Relations,Married,2,10/31/1938 +John,Kim Chi,Craft Services,Married,2,7/24/1990 +John,Lee,Accounting,Single,0,12/14/1988 +John,Littlejohn,Staff Parlementarian,Divorced,0,10/31/1938 +John,Many Jars,Storage Acquisition Lead,Married,3,1/8/1960 +John,Milton,Chief Counsel,Single,2,6/6/1966 +John,Mud Head,Apian Research Lead,Married,7,1/2/1956 +John,Nephew,Temporal Paradox Resolution,Widowed,0,1/20/1474 +John,Nolan,Custodian,Married,2,10/31/1938 +John,O'Connor,Temporal Paradox Resolution,Widowed,1,5/15/2022 +John,Omar,Imports & Exports,Single,0,9/9/1963 +John,Parrot,Computer Design Specialist,Married,1,10/1/1970 +John,Rajeesh,Human Resources,Divorced,1,6/12/1982 +John,Ready to Fly,Aerial R&D,Married,1,7/4/1976 +John,Repeat Dance,Sales,Married,3,6/8/1949 +John,Roberts,Counsel,Married,0,4/1/1962 +John,Scott,Administration,Single,1,10/31/1938 +John,Shaw,Administration,Single,0,8/15/1984 +John,Small Berries,Orbital Ergonomitrics Team Leader,Married,3,10/17/1948 +John,Starbird,Orbital Ergonomitrics,Married,2,10/18/1948 +John,Take Cover,Security Administrator,Divorced,0,2/15/2019 +John,Thorny Stick,Sales,Married,0,8/15/1984 +John,Turk,System Administrator,Engaged,0,11/3/1986 +John,Two Horns,Paralegal,Married,0,8/15/1984 +John,Web,IT Support,Married,1,6/8/1949 +John,Whorfin,CEO / Lord,Single,0,10/31/1938 +John,Wood,Sales,Married,1,8/12/1948 +John,Wright,Orbital Mechanics Supervisor,Married,2,10/4/1985 +John,Ya Ya,Computer Design Specialist,Married,0,10/31/1938 \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 7701470..47a9e5a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,6 +7,7 @@
Home + Staff About
{% block base %} diff --git a/templates/staff.html b/templates/staff.html new file mode 100644 index 0000000..9a2bd7d --- /dev/null +++ b/templates/staff.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} + +{% block base %} +
+

Yoyodyne Propulsion Systems The future begins tomorrow

+
+ + + + + + + + + + + + {% for e in employees %} + + + + + + + + {% endfor %} + +
First NameLast NamePosition NameStatusHired
{{ e.first }}{{ e.last }}{{ e.position }}{{ e.status }}, {{ e.children }} children{{ e.hired }}
+
+
+{% endblock %}