[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: G
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: Generating contract Python tutorial |
Date: |
Tue, 21 Feb 2017 11:56:52 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant-frontend-examples.
The following commit(s) were added to refs/heads/master by this push:
new 00e4c27 Generating contract Python tutorial
00e4c27 is described below
commit 00e4c27a5f83471d50c290e233a9b7e5925fcf7d
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Feb 21 11:56:37 2017 +0100
Generating contract Python tutorial
---
Python/Makefile | 5 ---
Python/lib/Makefile | 7 ++++
.../tutorial/__pycache__/tutorial.cpython-35.pyc | Bin 602 -> 0 bytes
Python/tutorial/tutorial.py | 38 ++++++++++++---------
4 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/Python/Makefile b/Python/Makefile
deleted file mode 100644
index a565c6d..0000000
--- a/Python/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-all:
- pip3 install lib --install-option="--prefix=$(TALER_PREFIX)"
-
-check:
- python3 lib/pytaler/tests.py
diff --git a/Python/lib/Makefile b/Python/lib/Makefile
new file mode 100644
index 0000000..a4740f6
--- /dev/null
+++ b/Python/lib/Makefile
@@ -0,0 +1,7 @@
+# TALER_PREFIX must point to 'site-packages' dir.
+
+all:
+ pip3 install . --install-option="--prefix=$(TALER_PREFIX)"
+
+check:
+ python3 pytaler/tests.py
diff --git a/Python/tutorial/__pycache__/tutorial.cpython-35.pyc
b/Python/tutorial/__pycache__/tutorial.cpython-35.pyc
deleted file mode 100644
index 9b2dbeb..0000000
Binary files a/Python/tutorial/__pycache__/tutorial.cpython-35.pyc and
/dev/null differ
diff --git a/Python/tutorial/tutorial.py b/Python/tutorial/tutorial.py
index 294af4a..4238fd1 100644
--- a/Python/tutorial/tutorial.py
+++ b/Python/tutorial/tutorial.py
@@ -1,6 +1,13 @@
import flask
+from urllib.parse import urljoin
+from pytaler import amounts
+
+
app = flask.Flask(__name__)
+CURRENCY = "KUDOS"
+BACKEND_URL = "http://backend.test.taler.net/"
+
@app.route('/')
def index():
return flask.render_template('index.html')
@@ -8,7 +15,7 @@ def index():
@app.route('/donate')
def donate():
- resp = flask.Response()
+ resp = flask.Response(status=402)
resp.headers['X-Taler-Contract-Url'] = '/generate-contract'
return resp
@@ -16,34 +23,31 @@ def donate():
@app.route('/generate-contract')
def generate_contract():
- # 1. Generate order.
- # FIXME: pass to VALUE.FRACTION:CURRENCY notation.
-
- donation_amount = amounts.amount_get_zero("KUDOS")
-
order = dict(
nonce=flask.request.args.get("nonce"),
- amount=ARTICLE_AMOUNT,
- max_fee=dict(value=1, fraction=0, currency=CURRENCY),
+ amount=amounts.string_to_amount("1.0:%s" % CURRENCY),
+ max_fee=amounts.string_to_amount("1.0:%s" % CURRENCY),
products=[
dict(
- description="Essay: " + article_name.replace("_", " "),
+ description="Donation",
quantity=1,
product_id=0,
- price=ARTICLE_AMOUNT,
+ price=amount,
),
],
- fulfillment_url=make_url("/essay/" + quote(article_name)),
+ fulfillment_url=make_url("/fulfillment/"),
merchant=dict(
- instance=INSTANCE,
address="nowhere",
- name="Kudos Inc.",
+ name="Donation tutorial",
jurisdiction="none",
),
- extra=dict(article_name=article_name),
)
+ url = urljoin(BACKEND_URL, 'proposal')
-
- # 2. POST order to BE.
- # 3. Relay proposal to client.
+ r = requests.post(url, json=dict(order=order))
+ if r.status_code != 200:
+ logger.error("failed to POST to '%s'", url)
+ return r.status_code, r.text
+ proposal_resp = r.json()
+ return flask.jsonify(**proposal_resp)
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: Generating contract Python tutorial,
gnunet <=