-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp1.py
More file actions
51 lines (34 loc) · 1.61 KB
/
app1.py
File metadata and controls
51 lines (34 loc) · 1.61 KB
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
44
45
46
47
48
49
50
51
from flask import Flask , render_template , request
from numpy import average
import pandas as pd
import matplotlib.pyplot as plt
app=Flask(__name__)
@app.route("/", methods=["POST","GET"])
def index():
if request.method=="POST":
data=pd.read_csv('data.csv')
if request.form.get("ID")!=''and request.form.get('id_value')!='':
ID=request.form.get("ID")
id=int(request.form.get('id_value'))
if ID=='student_id' and id in data['Student id'].tolist():
lisst=data[data['Student id']==id]
course_id=lisst[' Course id'].tolist()
marks=lisst[' Marks'].tolist()
total=sum(marks)
return render_template('student.html',course_id=course_id,marks=marks,total=total,id=id)
elif ID =='course_id' and id in data[' Course id'].tolist():
lisst=data[data[' Course id']==int(request.form.get('id_value'))]
maxs=max((lisst[' Marks']).tolist())
avgs=average(lisst[' Marks'].tolist())
plt.hist(lisst[' Marks'])
plt.savefig('./static/histogram.png')
plt.close()
return render_template('course.html', maxs=maxs,avgs=avgs)
else:
return render_template('error.html')
else:
return render_template('error.html')
elif request.method=="GET":
return render_template('index.html')
if __name__=="__main__":
app.run()