Skip to content

Commit

Permalink
fix(rapidocr_api): Fixed issue #223
Browse files Browse the repository at this point in the history
  • Loading branch information
SWHL committed Oct 15, 2024
1 parent 2db34bf commit a07b9c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions api/rapidocr_api/api.py → api/rapidocr_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __call__(self, img: Image.Image) -> Dict:

@app.get("/")
async def root():
return {"message": "Welcome to RapidOCR Server!"}
return {"message": "Welcome to RapidOCR API Server!"}


@app.post("/ocr")
Expand All @@ -71,7 +71,7 @@ def main():
parser.add_argument("-p", "--port", type=int, default=9003, help="IP port")
args = parser.parse_args()

uvicorn.run("api:app", host=args.ip, port=args.port, reload=True)
uvicorn.run("rapidocr_api.main:app", host=args.ip, port=args.port, reload=True)


if __name__ == "__main__":
Expand Down
21 changes: 13 additions & 8 deletions api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
# @Contact: [email protected]
import sys
from pathlib import Path
from typing import List

import setuptools
from get_pypi_latest_version import GetPyPiLatestVersion


def read_txt(txt_path: str) -> List:
if not isinstance(txt_path, str):
txt_path = str(txt_path)

with open(txt_path, "r", encoding="utf-8") as f:
data = list(map(lambda x: x.rstrip("\n"), f))
return data


def get_readme():
root_dir = Path(__file__).resolve().parent.parent
readme_path = str(root_dir / "docs" / "doc_whl_rapidocr_api.md")
Expand All @@ -22,7 +32,7 @@ def get_readme():
try:
latest_version = obtainer(MODULE_NAME)
except ValueError:
latest_version = "0.0.0"
latest_version = "0.0.1"
VERSION_NUM = obtainer.version_add_one(latest_version)

if len(sys.argv) > 2:
Expand All @@ -45,12 +55,7 @@ def get_readme():
download_url="https://github.com/RapidAI/RapidOCR.git",
license="Apache-2.0",
include_package_data=True,
install_requires=[
"requests",
"rapidocr_onnxruntime",
"fastapi",
"uvicorn[standard]",
],
install_requires=read_txt("requirements.txt"),
packages=[MODULE_NAME],
package_data={"": ["*.ico", "*.css", "*.js", "*.html"]},
keywords=[
Expand All @@ -68,7 +73,7 @@ def get_readme():
python_requires=">=3.6,<3.13",
entry_points={
"console_scripts": [
f"{MODULE_NAME}={MODULE_NAME}.api:main",
f"{MODULE_NAME}={MODULE_NAME}.main:main",
],
},
)

0 comments on commit a07b9c2

Please sign in to comment.