Skip to content

Commit 50b2231

Browse files
committed
site update
1 parent 377f0a0 commit 50b2231

File tree

7 files changed

+16
-8
lines changed

7 files changed

+16
-8
lines changed

site/app.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ def upload_file():
3636
def uploaded_file(filename):
3737
matrix = image_to_matrix(UPLOAD_FOLDER + filename)
3838
matrix_normal = [ls.tolist() for ls in matrix]
39-
print ("Got " + json.dumps(matrix_normal))
4039
return render_template('sudoku.html', matrix=json.dumps(matrix_normal))
4140

42-
@app.route('/solve', methods=['GET'])
41+
@app.route('/solve', methods=['POST'])
4342
def solve():
44-
string = request.args.get('matrix')
45-
print ("got " + string)
43+
string = request.form['matrix']
4644
return jsonify(solve_sudoku(string))
4745
app.run(threaded=False)

site/static/js/sudoku.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,28 @@ const setTilesSize = () => {
4949
}
5050
console.log(final_sudoku);
5151
console.log(final_string);
52-
$.get("/solve", {
52+
$.post("/solve", {
5353
matrix: final_string
5454
},
5555
function(data, status){
56-
matrix = (data);
57-
console.log(matrix);
58-
updateGrid();
56+
matrix_temp = (data);
57+
console.log(matrix_temp);
58+
if (matrix_temp[0][0] === 0){
59+
console.log("okay");
60+
alert("Please check the sudoku as it is not solvable in the current state");
61+
}
62+
else {
63+
matrix = matrix_temp;
64+
updateGrid();
65+
alert("Sudoku has been solved");
66+
}
67+
5968
}
6069
);
6170
};
6271

6372
const updateGrid = () => {
73+
6474
for (let y = 0; y < 9; y++) {
6575
for (let x = 0; x < 9; x++) {
6676
const tile = document.getElementById(y + '--' + x);

site/sudoku/sudoku.so

64 Bytes
Binary file not shown.

site/uploads/431.jpg

13.2 KB
Loading

site/uploads/download.jpeg

6.99 KB
Loading

site/uploads/f.jpg

33.4 KB
Loading

site/uploads/try.jpg

10.4 KB
Loading

0 commit comments

Comments
 (0)