-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial6.py
52 lines (37 loc) · 1.2 KB
/
tutorial6.py
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
52
#integrating Html with Flask
from flask import Flask, render_template, url_for, redirect,request
app=Flask(__name__)
@app.route('/')
def welcome():
return render_template('index2.html')
@app.route('/success/<int:score>')
def success(score):
res=" "
if score>33:
res= "pass"
else:
res= "fail"
return render_template('results.html',result=res)
@app.route('/fail/<int:score>')
def fail(score):
return "you have failed the examination "+str(score)
@app.route('/results/<int:marks>')
def results(marks):
result=""
if marks>33:
return redirect(url_for("success",score= marks))
else:
result=fail
return redirect(url_for("fail",score= marks))
@app.route('/submit',methods=['POST','GET'])
def submit():
total_score=0
if request.method=="POST":
science=float(request.form['science'])
maths=float(request.form['maths'])
c=float(request.form['c'])
datascience=float(request.form['datascience'])
total_score=(science +maths+c+datascience)/4
return redirect(url_for("success",score=total_score))
if __name__=='__main__':
app.run(debug=True)