Thiophai commited on
Commit
cb6cae0
·
verified ·
1 Parent(s): 0c49920

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +15 -1
main.py CHANGED
@@ -1,7 +1,7 @@
1
  import os
2
  import time
3
  import requests
4
- from fastapi import FastAPI, File, UploadFile
5
  from langchain_openai import ChatOpenAI
6
  from tempfile import NamedTemporaryFile
7
 
@@ -111,3 +111,17 @@ async def predict(file: UploadFile = File(...)):
111
  log_message(f"Overall /predict process took {overall_end - overall_start:.4f} seconds.")
112
 
113
  return {"prediction": prediction}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import time
3
  import requests
4
+ from fastapi import FastAPI, File, UploadFile, Response
5
  from langchain_openai import ChatOpenAI
6
  from tempfile import NamedTemporaryFile
7
 
 
111
  log_message(f"Overall /predict process took {overall_end - overall_start:.4f} seconds.")
112
 
113
  return {"prediction": prediction}
114
+
115
+ @app.get("/logs")
116
+ def get_logs():
117
+ """
118
+ Endpoint สำหรับดาวน์โหลด log file
119
+ """
120
+ log_file = "/app/logs/processing_logs.txt" # เปลี่ยนให้ตรงกับ path ที่กำหนดใน logger.py
121
+ if not os.path.exists(log_file):
122
+ return {"error": "Log file not found"}
123
+
124
+ with open(log_file, "r", encoding="utf-8") as f:
125
+ content = f.read()
126
+
127
+ return Response(content, media_type="text/plain")