diff --git a/paddlelabel_ml/__main__.py b/paddlelabel_ml/__main__.py index a7b99a5..2e99453 100644 --- a/paddlelabel_ml/__main__.py +++ b/paddlelabel_ml/__main__.py @@ -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( @@ -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__": diff --git a/requirements.txt b/requirements.txt index 7b2fcaf..4d79caa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ connexion[swagger-ui] Pillow opencv-python -numpy<=1.23.5 # till paddleocr fixes np.int +numpy tqdm flask_cors