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