inventory/inventory/routes/hooks.py
Yaro Kasear 9803db17ab Add inventory management templates and utility functions
- Created HTML templates for inventory index, layout, search, settings, table, user, and worklog.
- Implemented utility functions for eager loading relationships in SQLAlchemy.
- Added validation mixin for form submissions.
- Updated project configuration files (pyproject.toml and setup.cfg) for package management.
2025-07-08 11:47:22 -05:00

18 lines
601 B
Python

from bs4 import BeautifulSoup
from flask import current_app as app
from . import main
@main.after_request
def prettify_html_response(response):
if app.debug and response.content_type.startswith("text/html"):
try:
soup = BeautifulSoup(response.get_data(as_text=True), 'html5lib')
pretty_html = soup.prettify()
response.set_data(pretty_html.encode("utf-8")) # type: ignore
response.headers['Content-Type'] = 'text/html; charset=utf-8'
except Exception as e:
print(f"⚠️ Prettifying failed: {e}")
return response