JairoDanielMT commited on
Commit
7c6556e
1 Parent(s): 49cebb3
Files changed (2) hide show
  1. app/main.py +6 -11
  2. app/templates/AuditReport.html.j2 +3 -1
app/main.py CHANGED
@@ -3,8 +3,8 @@ from __future__ import annotations
3
  import io
4
  import re
5
  import unicodedata
6
- from urllib.parse import quote_from_bytes
7
  from typing import Any, Dict, Literal, Optional
 
8
 
9
  from fastapi import FastAPI, HTTPException
10
  from fastapi.responses import HTMLResponse, RedirectResponse, StreamingResponse
@@ -16,8 +16,7 @@ app = FastAPI(
16
  title="Doc Compiler Service",
17
  version="1.0.0",
18
  description=(
19
- "Servicio de compilaci贸n que recibe JSON de documentaci贸n, "
20
- "renderiza plantillas Jinja2 y devuelve HTML o PDF."
21
  ),
22
  )
23
 
@@ -26,15 +25,13 @@ class CompileRequest(BaseModel):
26
  doc: Dict[str, Any] = Field(
27
  ...,
28
  description=(
29
- "JSON de documentaci贸n generado por la IA "
30
- "(incluyendo metadata.script_type)."
31
  ),
32
  )
33
  job_id: Optional[str] = Field(
34
  None,
35
  description=(
36
- "Identificador opcional para el archivo "
37
- "(por ejemplo, nombre del script o job)."
38
  ),
39
  )
40
  output: Literal["html", "pdf"] = Field(
@@ -99,7 +96,7 @@ def compile_pdf(req: CompileRequest):
99
  filename = f"{safe_base}.pdf"
100
  encoded_name = quote_from_bytes(f"{raw_name}.pdf".encode("utf-8"))
101
  content_disposition = (
102
- f'attachment; filename="{filename}"; filename*=UTF-8\'\'{encoded_name}'
103
  )
104
  try:
105
  content_disposition.encode("latin-1")
@@ -109,7 +106,5 @@ def compile_pdf(req: CompileRequest):
109
  return StreamingResponse(
110
  io.BytesIO(pdf_bytes),
111
  media_type="application/pdf",
112
- headers={
113
- "Content-Disposition": content_disposition
114
- },
115
  )
 
3
  import io
4
  import re
5
  import unicodedata
 
6
  from typing import Any, Dict, Literal, Optional
7
+ from urllib.parse import quote_from_bytes
8
 
9
  from fastapi import FastAPI, HTTPException
10
  from fastapi.responses import HTMLResponse, RedirectResponse, StreamingResponse
 
16
  title="Doc Compiler Service",
17
  version="1.0.0",
18
  description=(
19
+ "Servicio de compilaci贸n que recibe JSON de documentaci贸n, renderiza plantillas Jinja2 y devuelve HTML o PDF."
 
20
  ),
21
  )
22
 
 
25
  doc: Dict[str, Any] = Field(
26
  ...,
27
  description=(
28
+ "JSON de documentaci贸n generado por la IA (incluyendo metadata.script_type)."
 
29
  ),
30
  )
31
  job_id: Optional[str] = Field(
32
  None,
33
  description=(
34
+ "Identificador opcional para el archivo (por ejemplo, nombre del script o job)."
 
35
  ),
36
  )
37
  output: Literal["html", "pdf"] = Field(
 
96
  filename = f"{safe_base}.pdf"
97
  encoded_name = quote_from_bytes(f"{raw_name}.pdf".encode("utf-8"))
98
  content_disposition = (
99
+ f"attachment; filename=\"{filename}\"; filename*=UTF-8''{encoded_name}"
100
  )
101
  try:
102
  content_disposition.encode("latin-1")
 
106
  return StreamingResponse(
107
  io.BytesIO(pdf_bytes),
108
  media_type="application/pdf",
109
+ headers={"Content-Disposition": content_disposition},
 
 
110
  )
app/templates/AuditReport.html.j2 CHANGED
@@ -106,7 +106,9 @@
106
  <h2>{{ file.path or file.name }}</h2>
107
  <div class="card-grid">
108
  {% if file.script_type %}<div class="card"><strong>Script type:</strong> {{ file.script_type }}</div>{% endif %}
109
- {% if file.score is not none %}<div class="card"><strong>Score:</strong> {{ file.score }}</div>{% endif %}
 
 
110
  {% if file.api_version %}<div class="card"><strong>API version:</strong> {{ file.api_version }}</div>{% endif %}
111
  </div>
112
  {% if file.overview %}
 
106
  <h2>{{ file.path or file.name }}</h2>
107
  <div class="card-grid">
108
  {% if file.script_type %}<div class="card"><strong>Script type:</strong> {{ file.script_type }}</div>{% endif %}
109
+ {% if file.score_0_10 is not none %}<div class="card"><strong>Audit score (0-10):</strong> {{ file.score_0_10 }}</div>{% endif %}
110
+ {% if file.final_score_0_100 is not none %}<div class="card"><strong>Final score (0-100):</strong> {{ file.final_score_0_100 }}</div>{% endif %}
111
+ {% if file.score is not none and file.score_0_10 is none and file.final_score_0_100 is none %}<div class="card"><strong>Score:</strong> {{ file.score }}</div>{% endif %}
112
  {% if file.api_version %}<div class="card"><strong>API version:</strong> {{ file.api_version }}</div>{% endif %}
113
  </div>
114
  {% if file.overview %}