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
wangsen
MinerU
Commits
792e08cf
Unverified
Commit
792e08cf
authored
Feb 14, 2025
by
shniubobo
Browse files
fix(web_api): Disallow both `pdf_file` and `pdf_path`
Also add some documentation.
parent
69e0e00e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
3 deletions
+26
-3
projects/web_api/app.py
projects/web_api/app.py
+26
-3
No files found.
projects/web_api/app.py
View file @
792e08cf
...
...
@@ -151,10 +151,33 @@ async def pdf_parse(
return_info
:
bool
=
False
,
return_content_list
:
bool
=
False
,
):
"""
Execute the process of converting PDF to JSON and MD, outputting MD and JSON files
to the specified directory.
:param pdf_file: The PDF file to be parsed. Must not be specified together with
`pdf_path`
:param pdf_path: The path to the PDF file to be parsed. Must not be specified
together with `pdf_file`
:param parse_method: Parsing method, can be auto, ocr, or txt. Default is auto. If
results are not satisfactory, try ocr
:param is_json_md_dump: Whether to write parsed data to .json and .md files. Default
is True. Different stages of data will be written to different .json files (3 in
total), md content will be saved to .md file
:param output_dir: Output directory for results. A folder named after the PDF file
will be created to store all results
:param return_layout: Whether to return parsed PDF layout. Default to False
:param return_info: Whether to return parsed PDF info. Default to False
:param return_content_list: Whether to return parsed PDF content list. Default to
False
"""
try
:
if
pdf_file
is
None
and
pdf_path
is
None
:
raise
HTTPException
(
status_code
=
400
,
detail
=
"Must provide either pdf_file or pdf_path"
if
(
pdf_file
is
None
and
pdf_path
is
None
)
or
(
pdf_file
is
not
None
and
pdf_path
is
not
None
):
return
JSONResponse
(
content
=
{
"error"
:
"Must provide either pdf_file or pdf_path"
},
status_code
=
400
,
)
# Get PDF filename
...
...
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