Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix debug and CORS #2

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions paddlelabel_ml/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import paddle

from paddlelabel_ml import util
from starlette.middleware.cors import CORSMiddleware
from connexion.middleware import MiddlewarePosition

HERE = Path(__file__).parent.absolute()


def parse_args():
parser = argparse.ArgumentParser(description="PaddleLabel ML")
parser.add_argument(
Expand Down Expand Up @@ -97,7 +98,18 @@ def run():
# logger.info("App starting")
print(f"PaddleLabel-ML is running at http://localhost:{args.port}")

connexion_app.run(host=host, port=args.port, debug=args.debug)

connexion_app.add_middleware(
CORSMiddleware,
position=MiddlewarePosition.BEFORE_EXCEPTION,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)

connexion_app.app.debug = args.debug
connexion_app.run(host=host, port=args.port)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ connexion[swagger-ui]

Pillow
opencv-python
numpy<=1.23.5 # till paddleocr fixes np.int
numpy
tqdm
flask_cors

Expand Down