From daf3366b62bcd893f7a917e292d97b214f422b3b Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Wed, 10 Apr 2024 16:51:15 +0200 Subject: [PATCH 1/2] Add CAPTCHA_SITE_KEY to .env.example, add local_run_api.sh to run API locally --- api/.env.example | 3 ++- api/scripts/local_run_api.sh | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 api/scripts/local_run_api.sh diff --git a/api/.env.example b/api/.env.example index 0d7993e..f158dc3 100644 --- a/api/.env.example +++ b/api/.env.example @@ -4,4 +4,5 @@ FAUCET_RPC_URL=https://rpc.chiadochain.net FAUCET_CHAIN_ID=10200 FAUCET_DATABASE_URI=sqlite:// CAPTCHA_VERIFY_ENDPOINT=https://api.hcaptcha.com/siteverify -CAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000 \ No newline at end of file +CAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000 +CAPTCHA_SITE_KEY=xxxxx-xxxxx-xxxxx-xxxxx \ No newline at end of file diff --git a/api/scripts/local_run_api.sh b/api/scripts/local_run_api.sh new file mode 100644 index 0000000..ebd5767 --- /dev/null +++ b/api/scripts/local_run_api.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail + + +echo "==> $(date +%H:%M:%S) ==> Migrating DB models... " +FLASK_APP=api python -m flask db upgrade + +echo "==> $(date +%H:%M:%S) ==> Running Gunicorn... " +exec gunicorn --bind localhost:8000 "api:create_app()" \ No newline at end of file From 2bc83daeedd28163a9ba10258fac098150df4ff3 Mon Sep 17 00:00:00 2001 From: Giacomo Licari Date: Wed, 10 Apr 2024 16:56:45 +0200 Subject: [PATCH 2/2] Log captcha verify response --- api/api/services/captcha.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/api/services/captcha.py b/api/api/services/captcha.py index e790800..b9d51c2 100644 --- a/api/api/services/captcha.py +++ b/api/api/services/captcha.py @@ -1,4 +1,8 @@ import requests +import logging + + +logging.basicConfig(level=logging.INFO) def captcha_verify(client_response, catpcha_api_url, secret_key, remote_ip, site_key): @@ -9,6 +13,8 @@ def captcha_verify(client_response, catpcha_api_url, secret_key, remote_ip, site 'sitekey': site_key }) + logging.info('Captcha verify response: %s' % request.json()) + if request.status_code != 200: return False return request.json()['success'] == True