-
Notifications
You must be signed in to change notification settings - Fork 201
/
main.py
54 lines (41 loc) · 1.26 KB
/
main.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
53
54
### Integrate HTML With Flask
### HTTP verb GET And POST
from flask import Flask,redirect,url_for,render_template,request
app=Flask(__name__)
@app.route('/')
def welcome():
return render_template('index.html')
@app.route('/success/<int:score>')
def success(score):
res=""
if score>=50:
res="PASS"
else:
res="FAIL"
return render_template('result.html',result=res)
@app.route('/fail/<int:score>')
def fail(score):
return "The Person has failed and the marks is "+ str(score)
### Result checker
@app.route('/results/<int:marks>')
def results(marks):
result=""
if marks<50:
result='fail'
else:
result='success'
return redirect(url_for(result,score=marks))
### Result checker submit html page
@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'])
data_science=float(request.form['datascience'])
total_score=(science+maths+c+data_science)/4
res=""
return redirect(url_for('success',score=total_score))
if __name__=='__main__':
app.run(debug=True)