【发布时间】:2021-06-03 02:31:45
【问题描述】:
from flask import Flask, request, abort, render_template
from News.News import News, news1_title, news1_topline
app = Flask(__name__)
app.register_blueprint(News, url_prefix="/News")
@app.route('/')
def index():
return render_template(
'index.html',
news1_title_html = news1_title,
news1_topline_html = news1_topline,
)
threading.Timer(30, index).start()
index()
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
我试图让 Flask 应用程序每 30 秒运行一次,以便为我的 Flask 服务器刷新来自新闻网站的解析数据。数据通过 html 模板 (index.html) 显示。我得到一个 AttributeError: 'NoneType' object has no attribute 'app' 并且 render_template 似乎有问题。
我对此很陌生,如果这是一个愚蠢的问题,对不起。
【问题讨论】:
标签: python flask timer attributeerror