linting
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from fastapi import FastAPI, HTTPException, File, UploadFile, Form, Request
|
from fastapi import FastAPI, HTTPException, File, UploadFile, Form, Request
|
||||||
|
|
||||||
# Backend (Python)
|
# Backend (Python)
|
||||||
# Add this to store progress globally
|
# Add this to store progress globally
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
@@ -10,7 +11,7 @@ scan_progress: Dict = {
|
|||||||
"current_file": "",
|
"current_file": "",
|
||||||
"indexed_count": 0,
|
"indexed_count": 0,
|
||||||
"total_files": 0,
|
"total_files": 0,
|
||||||
"progress": 0
|
"progress": 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Lock for thread-safe operations
|
# Lock for thread-safe operations
|
||||||
@@ -23,7 +24,6 @@ from fastapi.staticfiles import StaticFiles
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
import logging
|
import logging
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
from typing import List, Dict, Any, Optional, Union
|
from typing import List, Dict, Any, Optional, Union
|
||||||
@@ -36,7 +36,6 @@ from pathlib import Path
|
|||||||
import shutil
|
import shutil
|
||||||
import aiofiles
|
import aiofiles
|
||||||
from ascii_colors import trace_exception, ASCIIColors
|
from ascii_colors import trace_exception, ASCIIColors
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
@@ -1010,7 +1009,6 @@ def create_app(args):
|
|||||||
else:
|
else:
|
||||||
logging.warning(f"No content extracted from file: {file_path}")
|
logging.warning(f"No content extracted from file: {file_path}")
|
||||||
|
|
||||||
|
|
||||||
@app.post("/documents/scan", dependencies=[Depends(optional_api_key)])
|
@app.post("/documents/scan", dependencies=[Depends(optional_api_key)])
|
||||||
async def scan_for_new_documents():
|
async def scan_for_new_documents():
|
||||||
"""Trigger the scanning process"""
|
"""Trigger the scanning process"""
|
||||||
@@ -1037,7 +1035,10 @@ def create_app(args):
|
|||||||
|
|
||||||
with progress_lock:
|
with progress_lock:
|
||||||
scan_progress["indexed_count"] += 1
|
scan_progress["indexed_count"] += 1
|
||||||
scan_progress["progress"] = (scan_progress["indexed_count"] / scan_progress["total_files"]) * 100
|
scan_progress["progress"] = (
|
||||||
|
scan_progress["indexed_count"]
|
||||||
|
/ scan_progress["total_files"]
|
||||||
|
) * 100
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error indexing file {file_path}: {str(e)}")
|
logging.error(f"Error indexing file {file_path}: {str(e)}")
|
||||||
@@ -1059,8 +1060,6 @@ def create_app(args):
|
|||||||
with progress_lock:
|
with progress_lock:
|
||||||
return scan_progress
|
return scan_progress
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/documents/upload", dependencies=[Depends(optional_api_key)])
|
@app.post("/documents/upload", dependencies=[Depends(optional_api_key)])
|
||||||
async def upload_to_input_dir(file: UploadFile = File(...)):
|
async def upload_to_input_dir(file: UploadFile = File(...)):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user