-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
35 lines (29 loc) · 866 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
31
32
33
34
35
from flask import Flask, jsonify, request
from move import Move
from battlesnakerequest import BattleSnakeRequest
app = Flask(__name__)
@app.route('/')
def info():
return jsonify({
"apiversion": "1",
"author": "John Boctor",
"color": "#228C22",
"head": "silly",
"tail": "sharp",
"version": "0.0.1-beta",
})
@app.route('/start', methods = ['POST'])
def start():
return jsonify()
@app.route('/end', methods = ['POST'])
def end():
return jsonify()
@app.route('/move', methods = ['POST'])
def index():
battle_snake_request = BattleSnakeRequest(request.json)
move = Move(battle_snake_request.getSnake(), battle_snake_request.getBoard())
response = {"move": move.getMove()}
print(response)
return jsonify(response)
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')