-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
78 lines (54 loc) · 1.58 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from flask import Flask, request, jsonify
import datetime
import concurrent.futures
import services
app = Flask(__name__) # Create a flask app
@app.route("/")
def base_route():
"""Default route, return the list of available routes"""
rank = "0.25"
rank_float = float(rank)
print(rank_float)
date = datetime.datetime.now()
print(date.strftime("%Y-%m-%d %H:%M:%S.%f"))
return jsonify(
{
"routes_available": [
{
"route": "/horse/<horseId>?category=",
"verb": "GET",
"description": "Return the horse results for current year",
}
]
}
)
@app.route("/horse/<horseId>")
def get_horse_results(horseId):
"""Returns the horse data.
UriParam:
horseId: the Horde id to filter
QueryParam:
category : optional category to filter on
Returns: the Horse object
"""
args = request.args
print(f"Category:{args.get('category', default=None, type=str)}")
# To be implemented
raise NotImplementedError()
# Set the correct methods for this route
@app.route("/horse/export-podium", methods=["TODO"])
def export_podium():
"""Return the podium per categories for 3 best horses.
Args:
The list of horses
Returns: the podium
"""
return jsonify({})
@app.errorhandler(404)
def resource_not_found(e):
return jsonify(error=str(e)), 404
@app.errorhandler(400)
def bad_request(e):
return jsonify(error=str(e)), 400
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8800)