File tree Expand file tree Collapse file tree 7 files changed +16
-8
lines changed Expand file tree Collapse file tree 7 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -36,12 +36,10 @@ def upload_file():
36
36
def uploaded_file (filename ):
37
37
matrix = image_to_matrix (UPLOAD_FOLDER + filename )
38
38
matrix_normal = [ls .tolist () for ls in matrix ]
39
- print ("Got " + json .dumps (matrix_normal ))
40
39
return render_template ('sudoku.html' , matrix = json .dumps (matrix_normal ))
41
40
42
- @app .route ('/solve' , methods = ['GET ' ])
41
+ @app .route ('/solve' , methods = ['POST ' ])
43
42
def solve ():
44
- string = request .args .get ('matrix' )
45
- print ("got " + string )
43
+ string = request .form ['matrix' ]
46
44
return jsonify (solve_sudoku (string ))
47
45
app .run (threaded = False )
Original file line number Diff line number Diff line change @@ -49,18 +49,28 @@ const setTilesSize = () => {
49
49
}
50
50
console . log ( final_sudoku ) ;
51
51
console . log ( final_string ) ;
52
- $ . get ( "/solve" , {
52
+ $ . post ( "/solve" , {
53
53
matrix : final_string
54
54
} ,
55
55
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
+
59
68
}
60
69
) ;
61
70
} ;
62
71
63
72
const updateGrid = ( ) => {
73
+
64
74
for ( let y = 0 ; y < 9 ; y ++ ) {
65
75
for ( let x = 0 ; x < 9 ; x ++ ) {
66
76
const tile = document . getElementById ( y + '--' + x ) ;
You can’t perform that action at this time.
0 commit comments