flaskTest2.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:smells-gud 作者: samlouiscohen 项目源码 文件源码
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-----
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号