Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,11 @@ from fastapi.responses import HTMLResponse, FileResponse
|
|
3 |
from fastapi.staticfiles import StaticFiles
|
4 |
from fastapi.templating import Jinja2Templates
|
5 |
import os
|
|
|
|
|
|
|
|
|
|
|
6 |
from utils.image_processor import extract_text_from_image
|
7 |
from utils.xlnet_model import get_similarity_score
|
8 |
from werkzeug.utils import secure_filename
|
@@ -14,9 +19,6 @@ app = FastAPI()
|
|
14 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
15 |
templates = Jinja2Templates(directory="templates")
|
16 |
|
17 |
-
UPLOAD_FOLDER = "static/uploads"
|
18 |
-
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
19 |
-
|
20 |
ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg"}
|
21 |
|
22 |
def allowed_file(filename):
|
@@ -70,6 +72,7 @@ async def evaluate(
|
|
70 |
|
71 |
except Exception as e:
|
72 |
return {"error": str(e)}
|
|
|
73 |
if __name__ == "__main__":
|
74 |
import uvicorn
|
75 |
uvicorn.run("app:app", host="0.0.0.0", port=7860)
|
|
|
3 |
from fastapi.staticfiles import StaticFiles
|
4 |
from fastapi.templating import Jinja2Templates
|
5 |
import os
|
6 |
+
|
7 |
+
# New ✅ (safe temp directory on Hugging Face)
|
8 |
+
UPLOAD_FOLDER = "/tmp/uploads"
|
9 |
+
os.makedirs(UPLOAD_FOLDER, exist_ok=True) # ← Move this AFTER defining UPLOAD_FOLDER
|
10 |
+
|
11 |
from utils.image_processor import extract_text_from_image
|
12 |
from utils.xlnet_model import get_similarity_score
|
13 |
from werkzeug.utils import secure_filename
|
|
|
19 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
20 |
templates = Jinja2Templates(directory="templates")
|
21 |
|
|
|
|
|
|
|
22 |
ALLOWED_EXTENSIONS = {"png", "jpg", "jpeg"}
|
23 |
|
24 |
def allowed_file(filename):
|
|
|
72 |
|
73 |
except Exception as e:
|
74 |
return {"error": str(e)}
|
75 |
+
|
76 |
if __name__ == "__main__":
|
77 |
import uvicorn
|
78 |
uvicorn.run("app:app", host="0.0.0.0", port=7860)
|