"docs/source/vscode:/vscode.git/clone" did not exist on "8eb17315c8824e256dcc81bff254fa1cdfba49d9"
Commit eb6926bd authored by zhougaofeng's avatar zhougaofeng
Browse files

Update pdf_client.py

parent 0e8f989e
...@@ -13,6 +13,20 @@ class ocrPdfClient: ...@@ -13,6 +13,20 @@ class ocrPdfClient:
def __init__(self, api_url): def __init__(self, api_url):
self.api_url = api_url self.api_url = api_url
def check_health(self):
health_check_url = f'{self.api_url}/health'
try:
response = requests.get(health_check_url)
if response.status_code == 200:
logger.info("Server is healthy and ready to process requests.")
return True
else:
logger.error(f'Server health check failed with status code:{response.status_code}')
return False
except requests.exceptions.RequestException as e:
logger.error(f'Health check request failed:{e}')
return False
def ocr_pdf_client(self, path, output_dir): def ocr_pdf_client(self, path, output_dir):
payload = { payload = {
"path": str(path), "path": str(path),
...@@ -27,7 +41,7 @@ class ocrPdfClient: ...@@ -27,7 +41,7 @@ class ocrPdfClient:
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
logger.error(f"OCR PDF API request failed: {e}") logger.error(f"OCR PDF API request failed: {e}")
return None return None
def parse_args(): def parse_args():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment