本帖最后由 thinkdogo 于 2022-12-25 23:05 编辑
本人新手,在学flask的时候遇到问题:- @indexRoute.route('/')
- def page_index():
- return render_template("index.html")
复制代码
以上代码正常运行;
代码修改如下:
- @indexRoute.route('/')
- def page_index():
- photos = DBphotos()
- result = photos.get_data()
- return render_template("index.html", result=result)
复制代码
修改成这段代码就报错:python KeyError: <weakref at 0x0000018692731350; to 'Flask' at 0x000001869149A8D0>
我以为是get_data出了问题,但是经过调,把代码放到def外,只用: - photos = DBphotos()
- result = photos.get_data()
- print(result)
复制代码结果又正常运行 请高手看看问题发生在哪里?谢谢
|