-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
45 lines (34 loc) · 985 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
36
37
38
39
40
41
42
43
44
45
# test cli
import json
import sys
import utils
from human import Human
from flask import Flask, request, jsonify
app = Flask( __name__ )
player = Human('human 1')
@app.route('/')
def main():
return 'Hello world!'
@app.route('/giveCard', methods=['POST'])
def giveCard():
jsonCard = request.get_json(force=True)
card = utils.jsonToCard(jsonCard)
player.giveCard(card)
return ''
@app.route('/getEstimate', methods=['POST'])
def getEstimate():
data = request.get_json(force=True)
estimate = player.getEstimate( data['trumpSuit'], data['invalidGuess'] )
return jsonify({'estimate': estimate})
@app.route('/getCard', methods=['POST'])
def getCard():
data = request.get_json(force=True)
print(data)
card = player.getCard( data['turns'], data['trumpSuit'] )
return jsonify(utils.cardToJson(card))
@app.route('/roundWon', methods=['POST'])
def roundWon():
player.roundWon()
return ''
if __name__ == ' __main__':
app.run()