diff --git a/app/controllers/api.py b/app/controllers/api.py index ddbdf67..e6f364d 100644 --- a/app/controllers/api.py +++ b/app/controllers/api.py @@ -64,7 +64,7 @@ def get_comments_count(request): def new_comment(request): try: - data = request.get_json() + data = request.json logger.info(data) # validate token: retrieve site entity diff --git a/app/controllers/mail.py b/app/controllers/mail.py index 43d4d9c..0c7ba87 100644 --- a/app/controllers/mail.py +++ b/app/controllers/mail.py @@ -20,6 +20,6 @@ def new_mail(request): except: logger.exception("new mail failure") - abort(400) + return response.text('BAD_REQUEST', status=400) - return "OK" + return response.text('OK') diff --git a/app/run.py b/app/run.py index 57ccb40..02262c0 100644 --- a/app/run.py +++ b/app/run.py @@ -59,7 +59,7 @@ processor.start(template_path) logger.info("Start Stacosys application") # enable CORS -cors = CORS(app, resources={r"/comments/*": {"origins": "*"}}) +cors = CORS(app, resources={r"/comments/*": {"origins": config.CORS_ORIGIN}}) # tune logging level if not config.DEBUG: diff --git a/config.py b/config.py index 03e769f..4d969dc 100644 --- a/config.py +++ b/config.py @@ -11,7 +11,8 @@ MAIL_URL = "http://localhost:8025/mbox" HTTP_ADDRESS = "0.0.0.0" HTTP_PORT = 8000 -HTTP_WORKERS = 4 +HTTP_WORKERS = 1 +CORS_ORIGIN = "*" SALT = "BRRJRqXgGpXWrgTidBPcixIThHpDuKc0"