From d07f40942672928aab480b6e66b0e4f9f90f62b8 Mon Sep 17 00:00:00 2001 From: Teddy-1024 <39016164+Teddy-1024@users.noreply.github.com> Date: Sat, 25 Jan 2025 16:05:07 +0000 Subject: [PATCH] Merge conflic: Update app.py --- app.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index c3a0b557..63c01d3a 100644 --- a/app.py +++ b/app.py @@ -20,7 +20,7 @@ from config import app_config, Config from controllers.core import routes_core from controllers.legal import routes_legal from controllers.user import routes_user -from extensions import db, csrf, cors, mail, oauth +from extensions import db, csrf, mail, oauth from helpers.helper_app import Helper_App # external from flask import Flask, render_template, jsonify, request, render_template_string, send_from_directory, redirect, url_for, session @@ -81,12 +81,13 @@ def make_session_permanent(): session.permanent = True csrf = CSRFProtect() -""" -cors = CORS() -db = SQLAlchemy() -mail = Mail() -oauth = OAuth() -""" +cors = CORS(app, resources={ + r"/static/*": { + "origins": [app.config["URL_HOST"]], + "methods": ["GET"], + "max_age": 3600 + } +}) csrf.init_app(app) cors.init_app(app) @@ -123,3 +124,16 @@ app.register_blueprint(routes_user) def console_log(value): Helper_App.console_log(value) return value +<<<<<<< HEAD + +@app.after_request +def add_cache_headers(response): + if request.path.startswith('/static/'): + # Cache static assets + response.headers['Cache-Control'] = 'public, max-age=31536000' + else: + # No caching for dynamic content + response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0' + return response +======= +>>>>>>> a5d77c11a435413c35315fe1c53b778a454279c8