def home():
print("hello")
#food = []
food = getAllFoods()
FullLength = len(food)
length1 = len(food)
g.db = connect_db()
#g.db.execute("INSERT INTO entries(food,attributes) VALUES('chicken')")
for x in range(FullLength):
for y in range(len(food[x])):
if len(food[x][y][1]) == "none" :
g.db.execute("INSERT INTO entries(food,attributes) VALUES(?,?)",[food[x][y][0],food[x][y][1]])
g.db.commit()
else:
g.db.execute("INSERT INTO entries(food,attributes) VALUES(?,?)",[food[x][y][0],food[x][y][1]])
g.db.commit()
g.db = connect_db()
#Get everything from entries
cur = g.db.execute('select * from entries')
#Create dictionary using list comprehension
entries = [dict(food=row[1], attributes = row[2]) for row in cur.fetchall()]
#Returns the html to user
return render_template('index.html', entries = entries)
#------Mail aspect of website-----
评论列表
文章目录