我實際上打算在燒瓶模板中打印for循環,我使用了不同的方法,但沒有在html頁面上出現,python代碼工作正常,我只是不知道如何用忍者來實現它。For loop在燒瓶中不可見的HTML頁面
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')
Results.html
<body>
<div>
{{ result }}
{{ clean }}
</div>
</body>