From 41ad7201e9ffb017406425c4a4c39e57b74bf55c Mon Sep 17 00:00:00 2001 From: tecnovert Date: Thu, 25 Jul 2019 23:30:27 +0200 Subject: [PATCH] html: template for active swaps. --- basicswap/http_server.py | 30 ++++++++++-------------------- templates/active.html | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 templates/active.html diff --git a/basicswap/http_server.py b/basicswap/http_server.py index e9d605f..1a8d188 100644 --- a/basicswap/http_server.py +++ b/basicswap/http_server.py @@ -91,20 +91,15 @@ class HttpHandler(BaseHTTPRequestHandler): def page_active(self, url_split, post_string): swap_client = self.server.swap_client - - content = html_content_start(self.server.title, self.server.title) \ - + '

Active Swaps

' - active_swaps = swap_client.listSwapsInProgress() - content += '' - content += '' - for s in active_swaps: - content += ''.format(s[0].hex(), s[1], getBidState(s[2])) - content += '
Bid IDOffer IDBid Status
{0}{1}{2}
' - - content += '

home

' - return bytes(content, 'UTF-8') + template = env.get_template('active.html') + return bytes(template.render( + title=self.server.title, + refresh=30, + h2=self.server.title, + active_swaps=[(s[0].hex(), s[1], getBidState(s[2])) for s in active_swaps], + ), 'UTF-8') def page_wallets(self, url_split, post_string): swap_client = self.server.swap_client @@ -469,19 +464,14 @@ class HttpHandler(BaseHTTPRequestHandler): def page_watched(self, url_split, post_string): swap_client = self.server.swap_client watched_outputs, last_scanned = swap_client.listWatchedOutputs() - ls_formatted = [] - for ls in last_scanned: - ls_formatted.append((getCoinName(ls[0]), ls[1])) - wo_formatted = [] - for wo in watched_outputs: - wo_formatted.append((wo[1].hex(), getCoinName(wo[0]), wo[2], wo[3], int(wo[4]))) + template = env.get_template('watched.html') return bytes(template.render( title=self.server.title, refresh=30, h2=self.server.title, - last_scanned=last_scanned, - watched_outputs=wo_formatted, + last_scanned=[(getCoinName(ls[0]), ls[1]) for ls in last_scanned], + watched_outputs=[(wo[1].hex(), getCoinName(wo[0]), wo[2], wo[3], int(wo[4])) for wo in watched_outputs], ), 'UTF-8') def page_index(self, url_split): diff --git a/templates/active.html b/templates/active.html new file mode 100644 index 0000000..1c4d266 --- /dev/null +++ b/templates/active.html @@ -0,0 +1,16 @@ +{% include 'header.html' %} + +

Active Swaps

+{% if refresh %} +

Page Refresh: {{ refresh }} seconds

+{% endif %} + + + +{% for s in active_swaps %} + +{% endfor %} +
Bid IDOffer IDBid Status
{{ s[0] }}{{ s[1] }}{{ s[2] }}
+ +

home

+