이모저모

python - flask에서 app.config['SEND_FILE_MAX_AGE_DEFAULT'] 본문

coding

python - flask에서 app.config['SEND_FILE_MAX_AGE_DEFAULT']

Jeo 2022. 1. 5. 19:21

디버깅에서는 캐싱 시간을 짧게 하기 위한 분기처리:)

from flask import Flask, render_template

def create_app():
    print("run:create_app()")
    app = Flask(__name__)

    # 이 조건을 달지 않으면, css같은 사항 변화를 12시간마다 체크한다. 즉 디버깅모드에서는 불편하므로, 디버깅시에는 1초로 변경하는 것.
    if app.config['DEBUG']:
        app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1

    @app.route('/')
    def index():
        return render_template("index.html")

    @app.errorhandler(404)
    def page_404(error):
        return render_template("404.html"), 404


    return app

'coding' 카테고리의 다른 글

Flask WTF - Form layout  (0) 2022.01.05
Flask WTF - CSRF 방어하기  (0) 2022.01.05
flask request _ hook, application context  (0) 2022.01.04
flask - 기본 routings  (0) 2022.01.04
'빡코'팀프로젝트 2탄 - 개발일지 (2)  (0) 2021.10.28
Comments