-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
39 lines (28 loc) · 940 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
from flask import Flask, jsonify, request
from flask_cors import CORS
from src.sudoku import Sudoku
app = Flask(__name__)
CORS(app)
@app.route('/tabueleiroJogavel',methods=['GET'])
def getTabuleiroJogavel():
sudoku = Sudoku()
sudoku.setTabuleiro()
sudoku.setTabuleiorJogavel()
return jsonify(sudoku.getJson(sudoku.linhas))
@app.route('/validaTabuleiro',methods=['POST'])
def validarTabuleiro():
sudoku = Sudoku()
tabuleiro = request.get_json()
status = sudoku.checaTabuleiro(tabuleiro['linhas'])
return jsonify(status)
@app.route('/preencheTabuleiro',methods=['POST'])
def PreencherTabuleiro():
sudoku = Sudoku()
tabuleiro = request.get_json()
status = sudoku.preencheTabuleiro(tabuleiro['linhas'])
return jsonify(status)
if __name__ == "__main__":
from waitress import serve
serve(app, host="0.0.0.0", port=8080)
else:
app.run(port=8080, host="localhost", debug=True)