当我使用python test.py
运行烧瓶,然后在浏览器中导航到http://localhost:5000时,我希望终端能够阅读:
test-1
test-2
test-3
仅在第一次运行test.py
时出现三个打印语句。之后,终端只会显示:
test-1
test-2
由于某种原因,在初始运行后没有重定向到第二页。是否存在某种奇怪的缓存废话?有人可以解释一下发生了什么吗?
from flask import Flask, redirect, url_for, send_from_directory
app = Flask(__name__)
@app.route('/')
def home():
print('test-2')
return redirect(url_for('page2'))
@app.route('/secondPage')
def page2():
print('test-3')
return send_from_directory('.', 'test_dashboard_4.html')
if __name__ == '__main__':
print('test-1')
app.run(debug=True)
谢谢!