[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-survey] branch master updated: Getting as far as "ex
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-survey] branch master updated: Getting as far as "exchange not configured" error |
Date: |
Mon, 20 Nov 2017 13:36:30 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository survey.
The following commit(s) were added to refs/heads/master by this push:
new 25e6fea Getting as far as "exchange not configured" error
25e6fea is described below
commit 25e6feaf8bdc0c16573a889f51d7de2d8b525750
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Nov 20 13:36:05 2017 +0100
Getting as far as "exchange not configured" error
---
talersurvey/survey/survey.py | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/talersurvey/survey/survey.py b/talersurvey/survey/survey.py
index ab02def..9e304ee 100644
--- a/talersurvey/survey/survey.py
+++ b/talersurvey/survey/survey.py
@@ -17,7 +17,11 @@
import flask
import os
import base64
+import requests
+import logging
from talersurvey.talerconfig import TalerConfig
+from urllib.parse import urljoin
+
base_dir = os.path.dirname(os.path.abspath(__file__))
app = flask.Flask(__name__, template_folder=base_dir)
@@ -27,6 +31,18 @@ tc = TalerConfig.from_env()
BACKEND_URL = tc["frontends"]["backend"].value_string(required=True)
CURRENCY = tc["taler"]["currency"].value_string(required=True)
app.config.from_object(__name__)
+logger = logging.getLogger(__name__)
+
+
+def backend_error(requests_response):
+ logger.error("Backend error: status code: "
+ + str(requests_response.status_code))
+ try:
+ return flask.jsonify(requests_response.json()),
requests_response.status_code
+ except json.decoder.JSONDecodeError:
+ logger.error("Backend error (NO JSON returned): status code: "
+ + str(requests_response.status_code))
+ return flask.jsonify(dict(error="Backend died, no JSON got from it")),
502
@app.context_processor
def utility_processor():
@@ -52,3 +68,17 @@ def utility_processor():
@app.route("/")
def index():
return flask.render_template("templates/index.html",
merchant_currency=CURRENCY)
+
address@hidden("/survey", methods=["GET", "POST"])
+def survey():
+ success = False
+ if flask.request.method == "POST":
+ r = requests.post(urljoin(BACKEND_URL, 'tip-authorize'),
+ json=dict(amount=dict(value=1, fraction=0,
currency=CURRENCY),
+ instance="Taler",
+ justification="Payment methods survey"))
+ if 200 != r.status_code:
+ return backend_error(r)
+ else:
+ success = True
+ return flask.render_template("templates/index.html", success=success)
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-survey] branch master updated: Getting as far as "exchange not configured" error,
gnunet <=