forked from hclivess/Bismuth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml_dappie.py
53 lines (43 loc) · 1.58 KB
/
html_dappie.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import sqlite3, time, keys, options
from bottle import route, run, static_file
(key, private_key_readable, public_key_readable, public_key_hashed, address) = keys.read() #import keys
config = options.Get()
config.read()
debug_level = config.debug_level_conf
ledger_path_conf = config.ledger_path_conf
full_ledger = config.full_ledger_conf
ledger_path = config.ledger_path_conf
hyper_path = config.hyper_path_conf
@route('/static/<filename>')
def server_static(filename):
return static_file(filename, root='static/')
@route('/')
def hello():
# redraw chart
if full_ledger == 1:
conn = sqlite3.connect(ledger_path)
else:
conn = sqlite3.connect(hyper_path)
c = conn.cursor()
html = []
for row in c.execute("SELECT * FROM transactions WHERE openfield LIKE ? ORDER BY block_height DESC LIMIT 500", ("html=" + '%',)):
html.append("Block: ")
html.append(str(row[0]))
html.append("<br>")
html.append("Time: ")
html.append(time.strftime("%Y/%m/%d,%H:%M:%S", time.gmtime(float(row[1]))))
html.append("<br>")
html.append("Author: ")
html.append(str(row[2]))
html.append("<br>")
html.append("Content: ")
html.append("<br><br>")
html.append(row[11].lstrip("html="))
html.append("<br><br>")
joined = str(''.join(html))
joined = joined.replace("<script", "(")
joined = joined.replace("script>", ")")
joined = joined.replace("http-equiv", "/http-equiv/")
joined = joined.replace("onload", "/onload/")
return joined
run(host='0.0.0.0', port=4585, debug=True)