From 06493f01436857c261f2281f35a2f5a6beef8eae Mon Sep 17 00:00:00 2001 From: F-Node-Karlsruhe Date: Sat, 26 Jun 2021 16:33:01 +0200 Subject: [PATCH] add expired.html --- app.py | 12 ++++++------ templates/expired.html | 22 ++++++++++++++++++++++ templates/pay.html | 40 ++++++++++++++++++---------------------- 3 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 templates/expired.html diff --git a/app.py b/app.py index 8658efb..b5477a0 100644 --- a/app.py +++ b/app.py @@ -5,7 +5,7 @@ from dotenv import load_dotenv import os import iota -from datetime import timedelta +from datetime import datetime, timedelta from flask_socketio import SocketIO from flask import (Flask, render_template, @@ -99,7 +99,7 @@ def proxy(slug): session['iota_ghost_user_token:'] = secrets.token_hex(16) - + user_token_hash = hashlib.sha256(str(session['iota_ghost_user_token:'] + slug).encode('utf-8')).hexdigest() if user_token_hash_exists(user_token_hash): @@ -107,15 +107,15 @@ def proxy(slug): if user_token_hash_valid(user_token_hash): return ghost.get_post(slug, get_exp_date(user_token_hash)) - - exp_date = pop_from_paid_db(user_token_hash) - return make_response('Access expired at %s' % exp_date) + return render_template('expired.html', exp_date = pop_from_paid_db(user_token_hash).strftime('%d.%m.%y %H:%M')) return ghost.get_post_payment(slug, render_template('pay.html', user_token_hash = user_token_hash, iota_address = get_iota_address(slug, iota_listener), - price = price_per_content)) + price = price_per_content, + exp_date = (datetime.now() + timedelta(hours = session_lifetime)) + .strftime('%d.%m.%y %H:%M'))) # socket endpoint to receive payment event diff --git a/templates/expired.html b/templates/expired.html new file mode 100644 index 0000000..eb3a130 --- /dev/null +++ b/templates/expired.html @@ -0,0 +1,22 @@ + + + +IOTA Pay-per-Content Gateway + + + +
+ +

Ghost IOTA Pay

+

Pay per content gateway for Ghost Blogs

+
+

Access expired

+
{{ exp_date }}
+ +
+
+

+
+
+ + \ No newline at end of file diff --git a/templates/pay.html b/templates/pay.html index 2e1cb9c..154ee74 100644 --- a/templates/pay.html +++ b/templates/pay.html @@ -1,7 +1,5 @@ - - -
+
-

+

Ghost IOTA Pay - +

-

Please pay {{ price }} IOTA to the following address and attach the displayed data.

-
+

Please pay {{ price }} IOTA to the following address and attach the displayed data

+
+
Access until
+

{{ exp_date }}

+

Address:
- {{ iota_address }} + class="custom-box">{{ iota_address }}

Data:
- {{ user_token_hash }} + class="custom-box">{{ user_token_hash }}


-
+

Waiting for payment ...