Skip to content

Commit 940ede6

Browse files
committed
Initial commit
0 parents  commit 940ede6

File tree

9 files changed

+1020
-0
lines changed

9 files changed

+1020
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/Include
2+
/Lib
3+
/node_modules
4+
/Scripts
5+
package-lock.json
6+
package.json
7+
pyvenv.cfg

app.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from flask import Flask, render_template, request, jsonify
2+
import json
3+
4+
app = Flask(__name__)
5+
6+
# Load holes data from JSON file
7+
with open('data/holes.json') as f:
8+
holes = json.load(f)
9+
10+
11+
@app.route('/')
12+
def index():
13+
holes_json = json.dumps(holes)
14+
return render_template('index.html', holes=holes, holes_json=holes_json)
15+
16+
17+
@app.route('/advice', methods=['POST'])
18+
def advice():
19+
data = request.json
20+
hole_number = data['hole']
21+
disc_type = data['disc_type']
22+
hole = next((h for h in holes if h['hole'] == hole_number), None)
23+
24+
if not hole:
25+
return jsonify({"advice": "Hole not found."})
26+
27+
advice_text = "Consider the following:"
28+
29+
# Determine advice based on hole details
30+
if hole['par'] <= 3:
31+
advice_text += " Use a mid-range disc and focus on accuracy."
32+
else:
33+
advice_text += " Use a driver for long distance."
34+
35+
if "water" in hole['obstacles']:
36+
advice_text += " Be cautious of water hazards."
37+
38+
if hole['elevation_change'] > 0:
39+
advice_text += " The hole has an uphill slope."
40+
41+
if hole['elevation_change'] < 0:
42+
advice_text += " The hole has a downhill slope."
43+
44+
# Determine throw style based on direction
45+
if hole['direction'] == 'right':
46+
advice_text += " Consider throwing a flick to curve right."
47+
elif hole['direction'] == 'left':
48+
advice_text += " Consider throwing a backhand to curve left."
49+
else:
50+
advice_text += " Keep your throw flat to fly as straight as possible."
51+
52+
# Add specific disc type advice
53+
if disc_type == "putter":
54+
advice_text += " Use a putter for short distance and precision."
55+
elif disc_type == "mid-range":
56+
advice_text += " Use a mid-range disc for moderate distance and accuracy."
57+
elif disc_type == "driver":
58+
advice_text += " Use a driver for maximum distance."
59+
60+
return jsonify({"advice": advice_text})
61+
62+
63+
if __name__ == '__main__':
64+
app.run(debug=True)

data/holes.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
[
2+
{
3+
"hole": 1,
4+
"par": 3,
5+
"distance": 250,
6+
"obstacles": [
7+
"trees"
8+
],
9+
"lat": 51.505,
10+
"lng": -0.09,
11+
"elevation_change": 10,
12+
"direction": "straight"
13+
},
14+
{
15+
"hole": 2,
16+
"par": 4,
17+
"distance": 350,
18+
"obstacles": [
19+
"bushes",
20+
"hill"
21+
],
22+
"lat": 51.506,
23+
"lng": -0.091,
24+
"elevation_change": -5,
25+
"direction": "right"
26+
},
27+
{
28+
"hole": 3,
29+
"par": 3,
30+
"distance": 280,
31+
"obstacles": [
32+
"water"
33+
],
34+
"lat": 51.507,
35+
"lng": -0.092,
36+
"elevation_change": 0,
37+
"direction": "left"
38+
},
39+
{
40+
"hole": 4,
41+
"par": 5,
42+
"distance": 500,
43+
"obstacles": [
44+
"trees",
45+
"bushes"
46+
],
47+
"lat": 51.508,
48+
"lng": -0.093,
49+
"elevation_change": 15,
50+
"direction": "straight"
51+
}
52+
]

screenshot1.png

1.11 MB
Loading

static/css/styles.css

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* static/css/styles.css */
2+
@tailwind base;
3+
@tailwind components;
4+
@tailwind utilities;
5+
6+
#map {
7+
height: 400px;
8+
}

0 commit comments

Comments
 (0)