Skip to content

Commit a5b5863

Browse files
committed
Update content and design
1 parent 3fc084a commit a5b5863

24 files changed

+171
-395
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
flask_session/
99
/*_session/
1010

11+
films.txt
12+
1113
####################################################
1214

1315
# Byte-compiled / optimized / DLL files

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In need of a website to use as a vehicle to play around with a few AWS services
88

99
This, then, is that 20-year-old static website ressurrected as a dynamic web application with a data model to speak of, using modern tools such Flask, SQLite, VS Code and Git.
1010

11-
<picture><img src="/static/images/film-series1.jpg"></picture>
11+
<picture><img src="/static/images/film-series1_2.jpg"></picture>
1212
More screenshots below.
1313

1414
## Disclaimer
@@ -27,6 +27,7 @@ N/A
2727
### Dependencies
2828

2929
* Flask==2.2.5
30+
* flask_session==0.5.0
3031

3132
### Usage
3233

@@ -63,11 +64,6 @@ $ echo $MAP_API_KEY
6364
## Author(s)
6465
* [@ggeerraarrdd](https://github.com/ggeerraarrdd/)
6566

66-
## Version History
67-
* 1.0.0
68-
* October 16, 2023
69-
* Minimum viable product
70-
7167
## Future Work
7268

7369
* Change database to PostgreSQL and migrate to AWS RDS
@@ -81,5 +77,7 @@ $ echo $MAP_API_KEY
8177
* The distribution code for CS50's Finance problem served as a template for the app.
8278

8379
## Screenshots
84-
<picture><img src="/static/images/film-series2.jpg"></picture>
85-
<picture><img src="/static/images/film-series3.jpg"></picture>
80+
<picture><img src="/static/images/film-series2_2.jpg"></picture>
81+
<picture><img src="/static/images/film-series3_2.jpg"></picture>
82+
<picture><img src="/static/images/film-series4_1.jpg"></picture>
83+
<picture><img src="/static/images/film-series5_1.jpg"></picture>

app.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# Configure application
1111
app = Flask(__name__)
12+
1213
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
1314
app.config['TEMPLATES_AUTO_RELOAD'] = True
1415

@@ -17,7 +18,7 @@
1718
app.config["SESSION_TYPE"] = "filesystem"
1819
Session(app)
1920

20-
# Configure CS50 Library to use SQLite database
21+
# Set SQLite database variable
2122
db = "lafs.db"
2223

2324
# Make sure Google Maps API key is set
@@ -30,16 +31,7 @@
3031
else:
3132
print("MAP_API_KEY set")
3233
map_api_key = os.environ.get("MAP_API_KEY")
33-
34-
35-
@app.after_request
36-
def after_request(response):
37-
"""Ensure responses aren't cached"""
38-
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0"
39-
response.headers["Expires"] = 0
40-
response.headers["Pragma"] = "no-cache"
41-
return response
42-
34+
4335

4436
@app.route("/", methods=["GET", "POST"])
4537
def index():
@@ -82,12 +74,18 @@ def series():
8274
# Populate Bottom Container
8375
# List of films and their scheduled showtimes for selected past series
8476

77+
# Temporary bypass to session timeouts
78+
try:
79+
current_series_id = session["current_series_id"]
80+
except KeyError:
81+
current_series_id = 1
82+
8583
if request.method == "POST":
8684

8785
# Get info of clicked series id
8886
series_id = int(request.form.get("series-id"))
8987

90-
if series_id == session["current_series_id"]:
88+
if series_id == current_series_id:
9189
return redirect("/")
9290
else:
9391
# Update session variable active_series_id
@@ -168,5 +166,3 @@ def org():
168166

169167
return render_template("org.html", series=series, schedules=schedules, series_ids=series_ids)
170168

171-
172-
# chrome://net-internals/#sockets

lafs.db

8 KB
Binary file not shown.

queries.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def get_info_series(db, series_id):
3737
query = query + "series_title, "
3838
query = query + "series_brief, "
3939
query = query + "series_poster, "
40+
query = query + "series_poster_url, "
4041
query = query + "series_display, "
4142
query = query + "color1, "
4243
query = query + "color2, "
@@ -98,7 +99,35 @@ def get_info_series_ids(db):
9899
cursor = connection.cursor()
99100

100101
# Query db
101-
query = "SELECT DISTINCT(series_id), series_display FROM series; "
102+
query = "SELECT DISTINCT(series_id), series_semester, series_year, series_display FROM series; "
103+
cursor.execute(query)
104+
105+
# Get rows
106+
rows = cursor.fetchall()
107+
108+
# Get the column names from cursor.description
109+
columns = [column[0] for column in cursor.description]
110+
111+
# Convert each row into a dictionary using zip
112+
result = [dict(zip(columns, row)) for row in rows]
113+
114+
return(result)
115+
116+
117+
def get_info_serieses(db):
118+
"""Get info of series ids."""
119+
120+
# Create connection and cursor
121+
connection = sqlite3.connect(db, check_same_thread=False)
122+
connection.row_factory = sqlite3.Row
123+
cursor = connection.cursor()
124+
125+
# Query db
126+
query = "SELECT DISTINCT(series_id), "
127+
query = query + "series_semester, "
128+
query = query + "series_year, "
129+
query = query + "series_display "
130+
query = query + "FROM series; "
102131
cursor.execute(query)
103132

104133
# Get rows

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Flask==2.2.5
2+
flask_session==0.5.0
423 KB
Loading
File renamed without changes.
File renamed without changes.
872 KB
Loading

0 commit comments

Comments
 (0)