-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (26 loc) · 1.12 KB
/
main.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
from flask import Flask, redirect, url_for, render_template, request
from solve import solve
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def index():
print(request.method)
board = [['','','','','','','','',''],['','','','','','','','',''],['','','','','','','','',''],['','','','','','','','',''],['','','','','','','','',''],['','','','','','','','',''],['','','','','','','','',''],['','','','','','','','',''],['','','','','','','','','']]
if request.method == 'POST' and request.form['submit_button'] == 'Solve':
data = request
input = []
data = request.values
allowed = ['1','2','3','4','5','6','7','8','9']
for x in range(9):
row = []
for y in range(9):
cell = data[f'cell-{x}-{y}']
if cell in allowed:
row.append(int(cell))
else:
row.append(0)
input.append(row)
board = solve(input)
return render_template("sudoku.html", board=board)
return render_template("sudoku.html", board=board)
if __name__ == "__main__":
app.run()