Spaces:
Sleeping
Sleeping
Update Summarization/main.py
Browse files- Summarization/main.py +5 -2
Summarization/main.py
CHANGED
@@ -3,6 +3,7 @@ from fastapi.responses import HTMLResponse, JSONResponse, FileResponse
|
|
3 |
from fastapi.templating import Jinja2Templates
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
import tempfile, os
|
|
|
6 |
|
7 |
from .app import summarize_document
|
8 |
from .appImage import caption_image
|
@@ -17,7 +18,9 @@ app.add_middleware(
|
|
17 |
allow_headers=["*"],
|
18 |
)
|
19 |
|
20 |
-
|
|
|
|
|
21 |
|
22 |
@app.get("/", response_class=HTMLResponse)
|
23 |
async def serve_home(request: Request):
|
@@ -44,4 +47,4 @@ async def serve_file(filename: str):
|
|
44 |
filepath = os.path.join(tempfile.gettempdir(), filename)
|
45 |
if os.path.exists(filepath):
|
46 |
return FileResponse(filepath)
|
47 |
-
return JSONResponse({"error": "File not found"}, status_code=404)
|
|
|
3 |
from fastapi.templating import Jinja2Templates
|
4 |
from fastapi.middleware.cors import CORSMiddleware
|
5 |
import tempfile, os
|
6 |
+
from pathlib import Path
|
7 |
|
8 |
from .app import summarize_document
|
9 |
from .appImage import caption_image
|
|
|
18 |
allow_headers=["*"],
|
19 |
)
|
20 |
|
21 |
+
# ✅ Fixed: Dynamic template path resolution
|
22 |
+
current_dir = Path(__file__).parent
|
23 |
+
templates = Jinja2Templates(directory=current_dir.parent / "templates")
|
24 |
|
25 |
@app.get("/", response_class=HTMLResponse)
|
26 |
async def serve_home(request: Request):
|
|
|
47 |
filepath = os.path.join(tempfile.gettempdir(), filename)
|
48 |
if os.path.exists(filepath):
|
49 |
return FileResponse(filepath)
|
50 |
+
return JSONResponse({"error": "File not found"}, status_code=404)
|