Skip to content

Commit b414896

Browse files
Created basic structure of the web, created a basic block and a genesis block
0 parents  commit b414896

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+77207
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
blockchain_light
2+
.idea

blockchain/blockchain.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from flask import Flask, render_template
2+
from time import time
3+
4+
5+
class Blockchain:
6+
def __init__(self):
7+
self.transactions = []
8+
self.chain = []
9+
# create the genesis block
10+
self.create_block(0, '00')
11+
12+
def create_block(self, nonce, previous_hash):
13+
"""
14+
Add a block of transactions to the blockchain
15+
"""
16+
block = {
17+
'block_number': len(self.chain) + 1,
18+
'timestamp': time(),
19+
'transactions': self.transactions,
20+
'nonce': nonce,
21+
'previous_hash': previous_hash
22+
}
23+
# reset the current list of transactions
24+
self.transactions = []
25+
self.chain.append(block)
26+
27+
28+
blockchain = Blockchain()
29+
30+
# instantiate a node
31+
32+
33+
app = Flask(__name__)
34+
35+
36+
@app.route("/")
37+
def index():
38+
return render_template('./index.html')
39+
40+
41+
if __name__ == '__main__':
42+
from argparse import ArgumentParser
43+
44+
parser = ArgumentParser()
45+
parser.add_argument('-p', '--port', default=5001, type=int, help='port to listen to')
46+
args = parser.parse_args()
47+
port = args.port
48+
49+
app.run(host='127.0.0.1', port=port, debug=True)

blockchain/static/css/custom.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
padding-top: 54px;
3+
}
160 Bytes
Loading
148 Bytes
Loading
201 Bytes
Loading
158 Bytes
Loading
146 Bytes
Loading

blockchain/static/vendor/DataTables/css/datatables.min.css

Lines changed: 139 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blockchain/static/vendor/DataTables/js/datatables.min.js

Lines changed: 479 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)