forked from Unstructured-IO/unstructured-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unstructuredio_api.py
47 lines (39 loc) · 1.63 KB
/
unstructuredio_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
import sys
if getattr(sys, 'frozen', False):
# we are running in a bundle
bundle_dir = sys._MEIPASS
else:
# we are running in a normal Python environment
bundle_dir = os.path.dirname(os.path.abspath(__file__))
os.environ['PATH'] = os.path.join(bundle_dir, 'tesseract') + os.pathsep + os.environ['PATH']
os.environ['PATH'] = os.path.join(bundle_dir, 'poppler', 'bin') + os.pathsep + os.environ['PATH']
os.environ['PATH'] = os.path.join(bundle_dir, 'pandoc') + os.pathsep + os.environ['PATH']
os.environ['PATH'] = os.path.join(bundle_dir, 'libreoffice', 'program') + os.pathsep + os.environ['PATH']
os.environ['PATH'] = os.path.join(bundle_dir, 'libreoffice') + os.pathsep + os.environ['PATH']
from pydantic_settings import BaseSettings, SettingsConfigDict
from prepline_general.api.app import app
class Config(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
unstapi_port: int = 6989
unstapi_host: str = "0.0.0.0"
unstapi_workers: int = 1
log_config: str = os.path.join("_internal", "config", "logger_config.yaml")
config = Config()
if __name__ == "__main__":
import uvicorn
# if os.name == "nt":
from multiprocessing import freeze_support
freeze_support()
print("The system is Windows.")
# else:
# print("The system is not Windows.")
uvicorn.run(
# "prepline_general.api.app:app",
app,
reload=False,
port=config.unstapi_port,
host=config.unstapi_host,
workers=config.unstapi_workers,
log_config=config.log_config,
)