-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
20 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,19 @@ | ||
''' | ||
Author: FutureMeng [email protected] | ||
Date: 2024-11-13 19:44:33 | ||
LastEditors: dt_4541218930 abcstorms@163.com | ||
LastEditTime: 2024-11-13 22:36:37 | ||
LastEditors: FutureMeng be_loving@163.com | ||
LastEditTime: 2024-11-14 15:47:27 | ||
FilePath: \MinerU\scripts\fastapitest.py | ||
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE | ||
''' | ||
from fastapi import FastAPI | ||
import urllib.request | ||
import os | ||
from magic_pdf.pipe.UNIPipe import UNIPipe | ||
from magic_pdf.rw.DiskReaderWriter import DiskReaderWriter | ||
from magic_pdf_parse_util import pdf_parse | ||
from . import magic_pdf_parse_util | ||
|
||
app = FastAPI() | ||
|
||
current_script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
local_image_dir = os.path.join(current_script_dir, 'images') | ||
image_dir = str(os.path.basename(local_image_dir)) | ||
|
||
@app.get("/hello") | ||
async def hello(): | ||
return 'Hello, World' | ||
|
||
@app.post("/parse_pdf") | ||
async def parse_pdf(imageUrl: str, parse_method: str = 'auto'): | ||
pdf_bytes = urllib.request.urlopen(imageUrl).read() | ||
content_list, md_content = pdf_parse(pdf_bytes, parse_method) | ||
content_list, md_content = magic_pdf_parse_util.pdf_parse(pdf_bytes, parse_method) | ||
return {"content_list": content_list, "md_content": md_content} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
echo "starting miner server" | ||
source /opt/mineru_venv/bin/activate | ||
cd /minerugw | ||
uvicorn app.main:app --host 0.0.0.0 --port 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters