feat(api): exposer le blueprint HTTP sécurisé Home Assistant (étape 4)
Co-authored-by: OpenAI/GPT-5.6-Luna-Pro <vibecoder@antoineve.me>
This commit is contained in:
@@ -18,7 +18,7 @@ import tomllib
|
||||
from collections.abc import Mapping
|
||||
|
||||
import sqlalchemy as sa
|
||||
from flask import Flask
|
||||
from flask import Flask, request
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
db = SQLAlchemy()
|
||||
@@ -197,6 +197,7 @@ def create_app(
|
||||
app.jinja_env.filters["date_fr"] = _date_fr
|
||||
app.jinja_env.filters["day_type_fr"] = _day_type_fr
|
||||
|
||||
from app.api import bp as api_bp
|
||||
from app.routes.dashboard import bp as dashboard_bp
|
||||
from app.routes.entries import bp as entries_bp
|
||||
from app.routes.reports import bp as reports_bp
|
||||
@@ -204,6 +205,13 @@ def create_app(
|
||||
app.register_blueprint(dashboard_bp)
|
||||
app.register_blueprint(entries_bp)
|
||||
app.register_blueprint(reports_bp)
|
||||
app.register_blueprint(api_bp)
|
||||
|
||||
@app.after_request
|
||||
def add_api_cache_policy(response):
|
||||
if request.path.startswith("/api/v1/"):
|
||||
response.headers["Cache-Control"] = "no-store"
|
||||
return response
|
||||
|
||||
with app.app_context():
|
||||
_migrate_db(app)
|
||||
|
||||
Reference in New Issue
Block a user