-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
30 lines (26 loc) · 811 Bytes
/
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
import os
from flask import (
Flask,
send_from_directory,
render_template,
request
)
from utils.utils import run_sim
import json
app = Flask(__name__, static_folder='frontend/build')
@app.route('/api/simulation', methods=["POST"])
def simulation():
data = request.get_json()
team1, team2, num_games = data['team1'], data['team2'], data['num_games']
print(team1, team2, num_games)
results = run_sim(team1, team2, num_games)
print(results)
return json.dumps(results)
# Serve React App
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def serve(path):
if path != "" and os.path.exists("frontend/build/" + path):
return send_from_directory('frontend/build', path)
else:
return send_from_directory('frontend/build', 'index.html')