Skip to content

Commit f2afdc4

Browse files
committed
changed file references, should wor now
1 parent 99074ec commit f2afdc4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.github/
2+
.gitignore
3+
Dockerfile

app/main.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from fastapi import FastAPI, Request, Form
22
from fastapi.templating import Jinja2Templates
33
from fastapi.responses import HTMLResponse
4-
from classifier_model import load_models, classify_text
4+
from app.classifier_model import load_models, classify_text
5+
import os
56

67
print("svc_texpose - starting")
78

@@ -11,15 +12,18 @@
1112
# Initialize FastAPI app
1213
app = FastAPI()
1314

14-
# Set up Jinja2 templates
15-
templates = Jinja2Templates(directory="templates")
15+
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) # Gets /app/app/
16+
TEMPLATES_DIR = os.path.join(BASE_DIR, "templates")
17+
18+
templates = Jinja2Templates(directory=TEMPLATES_DIR)
19+
1620

1721
@app.get("/", response_class=HTMLResponse)
1822
async def root(request: Request):
1923
return templates.TemplateResponse("index.html", {"request": request, "prediction": None, "input_text": ""})
2024

2125
@app.post("/classify", response_class=HTMLResponse)
22-
async def classify(request: Request, input_text: str = Form(...)):
26+
async def classify(request: Request, input_text: str = Form(default="")):
2327
if input_text.strip(): # Ensure input is not empty
2428
result = classify_text(input_text, model_ai_hum, model_llm, tokenizer)
2529
prediction = result["type"]

0 commit comments

Comments
 (0)