Skip to content

Commit c4721c8

Browse files
Update routes.py
1 parent 3f1a456 commit c4721c8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

server/routes.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
from flask import request, render_template, make_response
34

45
from server.webapp import flaskapp, cursor
@@ -9,23 +10,17 @@
910
def index():
1011
name = request.args.get('name')
1112
author = request.args.get('author')
12-
read = request.args.get('read')
13+
read = bool(request.args.get('read'))
1314

1415
if name:
1516
cursor.execute(
16-
"SELECT * FROM books WHERE name LIKE %s", ('%' + name + '%',)
17+
"SELECT * FROM books WHERE name LIKE '%" + name + "%'"
1718
)
1819
books = [Book(*row) for row in cursor]
1920

2021
elif author:
2122
cursor.execute(
22-
"SELECT * FROM books WHERE author LIKE %s", ('%' + author + '%',)
23-
)
24-
books = [Book(*row) for row in cursor]
25-
26-
elif read:
27-
cursor.execute(
28-
"SELECT * FROM books WHERE read LIKE %s", ('%' + read + '%',)
23+
"SELECT * FROM books WHERE author LIKE '%" + author + "%'"
2924
)
3025
books = [Book(*row) for row in cursor]
3126

0 commit comments

Comments
 (0)