-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (19 loc) · 721 Bytes
/
app.py
File metadata and controls
31 lines (19 loc) · 721 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
from flask import Flask, jsonify, render_template, request
import predictor
app = Flask(__name__)
@app.route("/")
def index():
"""Serve the main page."""
return render_template("index.html")
@app.route("/predict", methods=["POST"])
def predict():
"""Handle form submissions and return a prediction."""
data = request.get_json()
home_team = data.get("homeTeam")
away_team = data.get("awayTeam")
if not home_team or not away_team:
return jsonify({"error": "Both teams must be selected"}), 400
home_win = predictor.predict_winner(home_team, away_team)
return jsonify({"winner": home_team if home_win else away_team})
if __name__ == "__main__":
app.run(debug=True)