Enhance app configuration and prettify HTML responses; update requirements and fix button identifiers in settings template
This commit is contained in:
parent
7c15754cab
commit
4c36621eba
4 changed files with 28 additions and 8 deletions
17
routes.py
17
routes.py
|
@ -9,6 +9,7 @@ import pandas as pd
|
|||
import traceback
|
||||
import json
|
||||
import datetime
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
main = Blueprint('main', __name__)
|
||||
|
||||
|
@ -78,6 +79,22 @@ worklog_form_fields = {
|
|||
"notes": lambda log: {"label": "Notes", "type": "textarea", "value": log.notes or "", "rows": 15}
|
||||
}
|
||||
|
||||
@main.after_request
|
||||
def prettify_html_response(response):
|
||||
if app.debug and response.content_type.startswith("text/html"):
|
||||
try:
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
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
|
||||
|
||||
@main.route("/")
|
||||
def index():
|
||||
worklog_query = eager_load_worklog_relationships(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue