-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (20 loc) · 757 Bytes
/
Copy pathapp.py
File metadata and controls
28 lines (20 loc) · 757 Bytes
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
from flask import Flask, request, jsonify, make_response
from flask_cors import CORS
import json
from src.greedy import greedy
app = Flask(__name__)
cors = CORS(app, resources={"*": {"origins": "*"}})
@app.route("/gomoku/cpu", methods=['GET'])
def get_gomoku():
params = request.args
# {0: 'black', 1: 'white', Null: None}
gomoku_json = json.loads(params["current_square_list"])
# greedy
res_x, res_y = greedy.run(gomoku_json)
response = {"x": res_x, "y": res_y}
if 'param' in params:
response.setdefault('res', 'param is : ' + params.get('param'))
return make_response(jsonify(response))
# app.run(debug=False, host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))
if __name__ == '__main__':
app.run()