vkumartr commited on
Commit
4cf79ec
·
verified ·
1 Parent(s): 42349f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -30,16 +30,20 @@ logger = logging.getLogger(__name__)
30
  # MongoDB Configuration
31
  MONGODB_URI = os.getenv("MONGODB_URI")
32
  DATABASE_NAME = os.getenv("DATABASE_NAME")
33
- COLLECTION_NAME = os.getenv("COLLECTION_NAME")
34
-
35
- # Initialize MongoDB Connection
36
- client = MongoClient(MONGODB_URI)
37
- db = client[DATABASE_NAME]
38
 
39
  app = FastAPI(docs_url='/')
40
  use_gpu = False
41
  output_dir = 'output'
42
 
 
 
 
 
 
 
 
 
43
  # Initialize PaddleOCR
44
  ocr = PaddleOCR(use_angle_cls=True, lang='en')
45
 
@@ -58,8 +62,6 @@ s3_client = boto3.client(
58
  aws_access_key_id=AWS_ACCESS_KEY,
59
  aws_secret_access_key=AWS_SECRET_KEY
60
  )
61
- if not MONGODB_URI:
62
- raise ValueError("MONGODB_URL is not set. Please add it to Hugging Face secrets.")
63
 
64
  # Function to fetch file from S3
65
 
 
30
  # MongoDB Configuration
31
  MONGODB_URI = os.getenv("MONGODB_URI")
32
  DATABASE_NAME = os.getenv("DATABASE_NAME")
33
+ COLLECTION_NAME = os.getenv("COLLECTION_NAME","invoice_collection")
 
 
 
 
34
 
35
  app = FastAPI(docs_url='/')
36
  use_gpu = False
37
  output_dir = 'output'
38
 
39
+ if not MONGODB_URI:
40
+ raise ValueError("MONGODB_URL is not set. Please add it to Hugging Face secrets.")
41
+
42
+ # Initialize MongoDB Connection
43
+ client = MongoClient(MONGODB_URI)
44
+ db = client[DATABASE_NAME]
45
+ invoice_collection=db[COLLECTION_NAME]
46
+
47
  # Initialize PaddleOCR
48
  ocr = PaddleOCR(use_angle_cls=True, lang='en')
49
 
 
62
  aws_access_key_id=AWS_ACCESS_KEY,
63
  aws_secret_access_key=AWS_SECRET_KEY
64
  )
 
 
65
 
66
  # Function to fetch file from S3
67