【发布时间】:2017-07-18 12:47:37
【问题描述】:
我实际上是想在烧瓶模板中打印一个 for 循环,我使用了不同的方法但 html 页面上没有出现任何内容,python 代码工作正常,我只是不知道如何用 jinja 实现它。
Views.py
@app.route('/results', methods=['POST', 'GET'])
def results():
keyword = {'keyword': request.args.get('keyword')} # First Method
keyword = request.form['keyword'] # Second Method
num_tweets=5
for tweet in tweepy.Cursor(api.search,q=str(keyword)+
" -filter:retweets",
result_type='recent',
lang="en").items(num_tweets):
clean = re.sub(r"(?:@\S*|#\S*|http(?=.*://)\S*)", "", tweet.text)
result = cool.api(clean)
return render_template('pages/results.html')
结果.html
<body>
<div>
{{ result }}
{{ clean }}
</div>
</body>
【问题讨论】: