1- # FastAPI opcional: no se importa en tiempo de análisis para evitar fallos de mypy/CI.
2- # Uso local:
3- # python -m pip install "fastapi>=0.110" "uvicorn[standard]>=0.27"
4- # python -m diff_risk_dashboard.web
51from __future__ import annotations
62
73from typing import Any
84
5+ # Importes perezosos para no requerir fastapi/uvicorn en CI
96from .core import summarize_apv_json
107from .report import to_markdown
118
@@ -15,10 +12,9 @@ def create_app() -> Any:
1512 responses = __import__ ("fastapi.responses" , fromlist = ["HTMLResponse" ])
1613 FastAPI = getattr (fastapi , "FastAPI" )
1714 HTMLResponse = getattr (responses , "HTMLResponse" )
15+ app : Any = FastAPI (title = "Diff Risk Dashboard" )
1816
19- app = FastAPI (title = "Diff Risk Dashboard" )
20-
21- @app .get ("/" , response_class = HTMLResponse )
17+ @app .get ("/" , response_class = HTMLResponse ) # type: ignore[misc]
2218 def index () -> Any :
2319 return HTMLResponse (
2420 content = """
@@ -33,11 +29,10 @@ def index() -> Any:
3329 status_code = 200 ,
3430 )
3531
36- @app .post ("/summarize" , response_class = HTMLResponse )
32+ @app .post ("/summarize" , response_class = HTMLResponse ) # type: ignore[misc]
3733 async def summarize (file : Any ) -> Any :
3834 data = await file .read ()
39- text = data .decode ("utf-8" )
40- summary = summarize_apv_json (text )
35+ summary = summarize_apv_json (data .decode ("utf-8" ))
4136 md = to_markdown (summary ).replace ("&" , "&" ).replace ("<" , "<" ).replace (">" , ">" )
4237 return HTMLResponse (f"<pre>{ md } </pre>" , status_code = 200 )
4338
0 commit comments