abdulahad086 commited on
Commit
6f8a30e
·
verified ·
1 Parent(s): ff416b1

Upload folder using huggingface_hub

Browse files
backend/__pycache__/main.cpython-312.pyc CHANGED
Binary files a/backend/__pycache__/main.cpython-312.pyc and b/backend/__pycache__/main.cpython-312.pyc differ
 
backend/main.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  from fastapi import FastAPI
3
  from fastapi.staticfiles import StaticFiles
4
  from fastapi.responses import FileResponse
@@ -26,24 +25,22 @@ FRONTEND_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__f
26
  def index():
27
  return FileResponse(os.path.join(FRONTEND_PATH, "index.html"))
28
 
29
- # IMPORTANT: Mount the entire frontend directory to serve JS and CSS files
30
- app.mount("/", StaticFiles(directory=FRONTEND_PATH), name="frontend")
31
-
32
  @app.get("/download-sample")
33
  def download_sample():
34
  sample_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "data", "sample_data.txt")
35
  return FileResponse(sample_path, filename="sample_data.txt")
36
 
37
  class Question(BaseModel):
38
-
39
-
40
  question: str
41
 
42
  @app.post("/ask")
43
-
44
  def ask_endpoint(q: Question):
45
  """
46
  Accepts a JSON object with a 'question' key and returns an AI-generated answer based on retrieved documents.
47
  """
48
  answer = ask_question(q.question)
49
- return {"answer": answer}
 
 
 
 
 
 
1
  from fastapi import FastAPI
2
  from fastapi.staticfiles import StaticFiles
3
  from fastapi.responses import FileResponse
 
25
  def index():
26
  return FileResponse(os.path.join(FRONTEND_PATH, "index.html"))
27
 
 
 
 
28
  @app.get("/download-sample")
29
  def download_sample():
30
  sample_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "data", "sample_data.txt")
31
  return FileResponse(sample_path, filename="sample_data.txt")
32
 
33
  class Question(BaseModel):
 
 
34
  question: str
35
 
36
  @app.post("/ask")
 
37
  def ask_endpoint(q: Question):
38
  """
39
  Accepts a JSON object with a 'question' key and returns an AI-generated answer based on retrieved documents.
40
  """
41
  answer = ask_question(q.question)
42
+ return {"answer": answer}
43
+
44
+ # IMPORTANT: Mount the entire frontend directory at the END
45
+ # This ensures API routes above (like /ask and /upload) take priority!
46
+ app.mount("/", StaticFiles(directory=FRONTEND_PATH), name="frontend")