-
Notifications
You must be signed in to change notification settings - Fork 20
/
app.py
55 lines (44 loc) · 1.64 KB
/
app.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
55
from prediction import predict
from flask import Flask, render_template, request, flash
app = Flask(__name__)
app.config['SECRET_KEY'] = 'defaultkey'
@app.route('/', methods=['POST', 'GET'])
def get_data():
return render_template('index.html')
@app.route('/submit', methods=['POST', 'GET'])
def post():
if request.method == 'POST':
home_team = request.form['homeTeam']
away_team = request.form['awayTeam']
city = request.form['city']
toss_winner = request.form['tossWinner']
toss_decision = request.form['selector1']
print(home_team, away_team, city, toss_winner, toss_decision)
winner_team = predict(home_team, away_team, city, toss_winner, toss_decision).__str__()
print("Winning Team is -> " + winner_team)
home_team_name = convert_back_to_team_names(home_team).__str__()
away_team_name = convert_back_to_team_names(away_team).__str__()
flash("Match Prediction between " + home_team_name + " and " + away_team_name + " is higher for: " + winner_team)
return render_template('index.html')
# return render_template('results.html')
def convert_back_to_team_names(team):
team_name = ""
if team == 'Kolkata':
team_name = "KKR"
if team == "Bangalore":
team_name = "RCB"
if team == "Pune":
team_name = "CSK"
if team == "Jaipur":
team_name = "RR"
if team == "Delhi":
team_name = "DD"
if team == "Dharamshala":
team_name = "KXIP"
if team == "Hyderabad":
team_name = "SRH"
if team == "Mumbai":
team_name = "MI"
return team_name
if __name__ == '__main__':
app.run()