-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrun.py
More file actions
31 lines (26 loc) · 809 Bytes
/
run.py
File metadata and controls
31 lines (26 loc) · 809 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
from flask import Flask
from flask import render_template
import json
app = Flask(__name__)
def read_json_file(filepath):
jsonfile = open(filepath, 'r+')
jsontext = jsonfile.read()
data = json.loads(jsontext)
jsonfile.close()
return data
@app.route('/')
def hello_world():
data = read_json_file('static/data/index.json')
return render_template('index.html', data=data)
@app.route('/details/<string:student_number>')
def look_details(student_number):
data = read_json_file('static/data/index.json')
user_data = {}
for item in data:
if student_number == item['student_number']:
user_data = item
break
print user_data
return render_template('details.html', data=user_data)
if __name__ == '__main__':
app.run(debug=True)