Files
aio_html_generator/app/__init__.py
Mateusz Gruszczyński 13734e585b small
2026-02-26 15:15:46 +01:00

40 lines
1.1 KiB
Python

from flask import Flask, request, render_template
from .config import Config
from .api import api_bp
def create_app():
app = Flask(__name__)
app.config.from_object(Config)
app.register_blueprint(api_bp, url_prefix='/api')
@app.route('/favicon.ico')
def favicon():
return '', 204
@app.after_request
def add_cache_headers(response):
if request.path.startswith('/static/'):
max_age = app.config['STATIC_CACHE_MAX_AGE']
response.headers['Cache-Control'] = f'public, max-age={max_age}'
return response
@app.after_request
def remove_content_disposition(response):
response.headers.pop('Content-Disposition', None)
return response
@app.route('/')
def index():
template_vars = {
'APP_TITLE': app.config['APP_TITLE'],
'APP_FOOTER': app.config['APP_FOOTER']
}
return render_template('main.html', config=template_vars)
@app.route('/api/health')
def health():
return {'status': 'OK'}
return app