Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
zhougaofeng
magic_pdf
Commits
eb6926bd
Commit
eb6926bd
authored
Oct 24, 2024
by
zhougaofeng
Browse files
Update pdf_client.py
parent
0e8f989e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
magic_pdf/parse/pdf_client.py
magic_pdf/parse/pdf_client.py
+15
-1
No files found.
magic_pdf/parse/pdf_client.py
View file @
eb6926bd
...
...
@@ -13,6 +13,20 @@ class ocrPdfClient:
def
__init__
(
self
,
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
):
payload
=
{
"path"
:
str
(
path
),
...
...
@@ -27,7 +41,7 @@ class ocrPdfClient:
except
requests
.
exceptions
.
RequestException
as
e
:
logger
.
error
(
f
"OCR PDF API request failed:
{
e
}
"
)
return
None
def
parse_args
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment