我的数据库中有1000多个项目,我想在我的网站上显示这些产品。这些条目作为字典获取。我在StackOverflow上搜索了这个问题。我找到了一些东西,但这些东西是作为一个列表提取的
@app.route("/",methods = ["GET","POST"])
def index():
if request.method == "GET":
cursor = mysql.connection.cursor()
sorgu = "SELECT * from all_products"
result = cursor.execute(sorgu)
if result > 0:
products = cursor.fetchall()
totalproducts = len(products)
totalproductsinpage = countproductsall(products)
success = int((totalproducts - totalproductsinpage )* 100 / totalproducts)
return render_template("index.html",products = products,totalproducts = totalproducts,totalproductsinpage = totalproductsinpage,success = success)
else:
flash("Ürün bulunamadı!","warning")
return render_template("index.html")
目前没有回答
相关问题 更多 >
编程相关推荐