我目前正在运行最新版本的Ubuntu,我正在使用PyCharm构建我的第一个Flask应用程序 .
我一直尝试everything on here尝试在我编辑模板文件夹中的html文件时自动重新加载 .
每当我更改 app.py
文件时,我都会收到一条消息说
检测到'/home/GoogleDrive/Code/Websites/program/app.py'中的更改,重新加载
这就是我的 app.py
文件的样子
from flask import Flask, render_template, request
app = Flask(__name__)
app.config['TEMPLATES_AUTO_RELOAD'] = True
@app.route("/")
def index():
return render_template('index.html')
@app.after_request
def apply_caching(response):
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
return response
def before_request():
app.jinja_env.cache = {}
if __name__ == "__main__":
app.before_request(before_request)
app.config.update(
DEBUG=True,
TESTING=True,
TEMPLATES_AUTO_RELOAD=True
)
app.run(debug=True)