-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
43 lines (30 loc) · 1018 Bytes
/
app.py
File metadata and controls
43 lines (30 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/hello')
def hello_world():
return 'Hello World!'
def get_films_from_file():
with open ("film_ratings.txt", 'r') as f:
lines = f.read().splitlines()
return lines
def get_films_from_file_split():
with open ("film_ratings.txt", 'r') as file:
split_lines = [line.split(',') for line in file.read().splitlines()]
return split_lines
@app.route('/films/list')
def get_films():
list = get_films_from_file()
return render_template('film_list.html', films=list)
@app.route('/films/list_two')
def get_films2():
return app.send_static_file("filmlist.html")
@app.route('/films/table')
def get_table():
print("test1")
films = []
split_lines = get_films_from_file_split()
films = [{'film_name': film_name, 'stars': stars}
for [film_name, stars] in split_lines]
return render_template('film_table.html', films=films)
#if __name__ == '__main__':
# app.run()