from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse, JSONResponse from fastapi.staticfiles import StaticFiles from transformers import pipeline app = FastAPI() # Uncomment and set up the model if needed # model = pipeline('question-answering', model='bert-large-uncased-whole-word-masking-finetuned-squad', revision='main') # Serve static files (e.g., CSS, JS, images) app.mount("/static", StaticFiles(directory="static"), name="static") @app.get("/", response_class=HTMLResponse) async def home(request: Request): with open("templates/index.html") as f: html_content = f.read() return HTMLResponse(content=html_content) @app.post("/predict", response_class=JSONResponse) async def predict(request: Request): data = await request.json() user_input = data.get('message') # result = model(user_input) # response_text = result[0]['generated_text'] return JSONResponse(content={'response': "Hello, Hugging Face!"}) # response_text