def searchBookByPrice(): if request.method == 'POST': user = request.cookies.get('name') userid = bm.checkUseridByName(user) beginprice = request.form['beginprice'] endprice = request.form['endprice'] res = bm.checkBookByPrice(beginprice, endprice, userid) return render_template('list.html', prolist=res, userinfo=user)
def insertbook(): if request.method == 'GET': user = request.cookies.get('name') return render_template('insertbook.html', userinfo=user) elif request.method == 'POST': bookname = request.form['bookname'] author = request.form['author'] price = request.form['price'] abstract = request.form['abstract'] user = request.cookies.get('name') userid = bm.checkUseridByName(user) try: bm.insertBook(bookname, author, price, abstract, userid) return redirect('/list') except: return redirect('/insertbook')
def checkBookByPriceAsc(): user = request.cookies.get('name') userid = bm.checkUseridByName(user) res = bm.checkBookByPriceAsc(userid) return render_template('list.html', prolist=res, userinfo=user)