├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── _config.yml ├── blockchain ├── __init__.py └── chain.py ├── bscli.py ├── setup.py ├── templates ├── blockdata.html ├── blocks.html └── guide.html └── web.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | chain.txt 3 | venv/ 4 | build/ 5 | dist/ 6 | blockshell/ 7 | blockshell.egg-info/ 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at daxeelsoni44@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Try and play around Blockshell. If you found any bugs or want to integrate new feature, feel free to submit PR. 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Daxeel Soni 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 📖 README.md just includes installation guide. You can find detailed guide in this wiki page 2 | 3 | # BlockShell 4 | A command line utility for learning Blockchain technical concepts likechaining, mining, proof of work etc. 5 | 6 | 7 | 8 | 9 | ## ℹ️ About 10 | Anyone who wants to understand how blockchain technology works, then BlockShell should be a great start. Because I have created BlockShell keeping blockchain fundamentals in the center of development. With BlockShell you will actually create a tiny blockchain in your system where you can create blocks with data, explore blocks etc. 11 | 12 | So, by using BlockShell anyone can learn following blockchain concepts, 13 | * Block & Chaining 14 | * Hashing 15 | * Mining 16 | * Proof of Work 17 | 18 | ## 🌐 BlockShell Web Explorer 19 |

BlockShell comes with built-in blockchain explorer by which you can actully see how blocks are mined and what is stored and where.

20 | 21 | Latest Mined Blocks | Block Details 22 | :------------------------------:|:-------------------------: 23 | ![](https://preview.ibb.co/iZa5jG/Screen_Shot_2018_01_25_at_11_25_22_PM.png) | ![](https://preview.ibb.co/cDB0Jb/Screen_Shot_2018_01_25_at_11_25_35_PM.png) 24 | 25 | ## 📦 Installation 26 | Step 1 - Create project directory 27 | ``` 28 | mkdir && cd project_name 29 | ``` 30 | 31 | Step 2 - Create new virtual environment with python version 2.7. 32 | ``` 33 | virtualenv venv 34 | ``` 35 | 36 | Step 3 - Activate virtual environment 37 | ``` 38 | source venv/bin/activate 39 | ``` 40 | or 41 | ``` 42 | source venv/Scripts/activate 43 | ``` 44 | 45 | Step 4 - Clone this repo 46 | ``` 47 | git clone https://github.com/daxeel/blockshell.git 48 | ``` 49 | 50 | Step 5 - Change directory to cloned one 51 | ``` 52 | cd blockshell 53 | ``` 54 | 55 | Step 6 - Install blockshell 56 | ``` 57 | pip install --editable . 58 | ``` 59 | 60 | Step 7 - Try "blockshell" command and test installation! 61 | ``` 62 | blockshell 63 | ``` 64 | 65 | Output in terminal after calling BlockShell command 66 | 67 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /blockchain/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daxeel/blockshell/f23af007d8a65a3a265f8db4430d15c843479aff/blockchain/__init__.py -------------------------------------------------------------------------------- /blockchain/chain.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # =================================================== 3 | # ==================== META DATA =================== 4 | # ================================================== 5 | __author__ = "Daxeel Soni" 6 | __url__ = "https://daxeel.github.io" 7 | __email__ = "daxeelsoni44@gmail.com" 8 | __license__ = "MIT" 9 | __version__ = "0.1" 10 | __maintainer__ = "Daxeel Soni" 11 | 12 | # ================================================== 13 | # ================= IMPORT MODULES ================= 14 | # ================================================== 15 | import hashlib 16 | import datetime 17 | import json 18 | from colorama import Fore, Back, Style 19 | import time 20 | import sys 21 | 22 | # ================================================== 23 | # =================== BLOCK CLASS ================== 24 | # ================================================== 25 | class Block: 26 | """ 27 | Create a new block in chain with metadata 28 | """ 29 | def __init__(self, data, index=0): 30 | self.index = index 31 | self.previousHash = "" 32 | self.data = data 33 | self.timestamp = str(datetime.datetime.now()) 34 | self.nonce = 0 35 | self.hash = self.calculateHash() 36 | 37 | def calculateHash(self): 38 | """ 39 | Method to calculate hash from metadata 40 | """ 41 | hashData = str(self.index) + str(self.data) + self.timestamp + self.previousHash + str(self.nonce) 42 | return hashlib.sha256(hashData).hexdigest() 43 | 44 | def mineBlock(self, difficulty): 45 | """ 46 | Method for Proof of Work 47 | """ 48 | print Back.RED + "\n[Status] Mining block (" + str(self.index) + ") with PoW ..." 49 | startTime = time.time() 50 | 51 | while self.hash[:difficulty] != "0"*difficulty: 52 | self.nonce += 1 53 | self.hash = self.calculateHash() 54 | 55 | endTime = time.time() 56 | print Back.BLUE + "[ Info ] Time Elapsed : " + str(endTime - startTime) + " seconds." 57 | print Back.BLUE + "[ Info ] Mined Hash : " + self.hash 58 | print Style.RESET_ALL 59 | 60 | # ================================================== 61 | # ================ BLOCKCHAIN CLASS ================ 62 | # ================================================== 63 | class Blockchain: 64 | """ 65 | Initialize blockchain 66 | """ 67 | def __init__(self): 68 | self.chain = [self.createGenesisBlock()] 69 | self.difficulty = 3 70 | 71 | def createGenesisBlock(self): 72 | """ 73 | Method create genesis block 74 | """ 75 | return Block("Genesis Block") 76 | 77 | def addBlock(self, newBlock): 78 | """ 79 | Method to add new block from Block class 80 | """ 81 | newBlock.index = len(self.chain) 82 | newBlock.previousHash = self.chain[-1].hash 83 | newBlock.mineBlock(self.difficulty) 84 | self.chain.append(newBlock) 85 | self.writeBlocks() 86 | 87 | def writeBlocks(self): 88 | """ 89 | Method to write new mined block to blockchain 90 | """ 91 | dataFile = file("chain.txt", "w") 92 | chainData = [] 93 | for eachBlock in self.chain: 94 | chainData.append(eachBlock.__dict__) 95 | dataFile.write(json.dumps(chainData, indent=4)) 96 | dataFile.close() 97 | -------------------------------------------------------------------------------- /bscli.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # =================================================== 3 | # ==================== META DATA =================== 4 | # ================================================== 5 | __author__ = "Daxeel Soni" 6 | __url__ = "https://daxeel.github.io" 7 | __email__ = "daxeelsoni44@gmail.com" 8 | __license__ = "MIT" 9 | __version__ = "0.1" 10 | __maintainer__ = "Daxeel Soni" 11 | 12 | # ================================================== 13 | # ================= IMPORT MODULES ================= 14 | # ================================================== 15 | import click 16 | import urllib 17 | import json 18 | from blockchain.chain import Block, Blockchain 19 | 20 | # ================================================== 21 | # ===== SUPPORTED COMMANDS LIST IN BLOCKSHELL ====== 22 | # ================================================== 23 | SUPPORTED_COMMANDS = [ 24 | 'dotx', 25 | 'allblocks', 26 | 'getblock', 27 | 'help' 28 | ] 29 | 30 | # Init blockchain 31 | coin = Blockchain() 32 | 33 | # Create group of commands 34 | @click.group() 35 | def cli(): 36 | """ 37 | Create a group of commands for CLI 38 | """ 39 | pass 40 | 41 | # ================================================== 42 | # ============= BLOCKSHELL CLI COMMAND ============= 43 | # ================================================== 44 | @cli.command() 45 | @click.option("--difficulty", default=3, help="Define difficulty level of blockchain.") 46 | def init(difficulty): 47 | """Initialize local blockchain""" 48 | print """ 49 | ____ _ _ _____ _ _ _ 50 | | _ \ | | | | / ____| | | | | | | 51 | | |_) | | | ___ ___ | | __ | (___ | |__ ___ | | | | 52 | | _ < | | / _ \ / __| | |/ / \___ \ | '_ \ / _ \ | | | | 53 | | |_) | | | | (_) | | (__ | < ____) | | | | | | __/ | | | | 54 | |____/ |_| \___/ \___| |_|\_\ |_____/ |_| |_| \___| |_| |_| 55 | 56 | > A command line utility for learning Blockchain concepts. 57 | > Type 'help' to see supported commands. 58 | > Project by Daxeel Soni - https://daxeel.github.io 59 | 60 | """ 61 | 62 | # Set difficulty of blockchain 63 | coin.difficulty = difficulty 64 | 65 | # Start blockshell shell 66 | while True: 67 | cmd = raw_input("[BlockShell] $ ") 68 | processInput(cmd) 69 | 70 | # Process input from Blockshell shell 71 | def processInput(cmd): 72 | """ 73 | Method to process user input from Blockshell CLI. 74 | """ 75 | userCmd = cmd.split(" ")[0] 76 | if len(cmd) > 0: 77 | if userCmd in SUPPORTED_COMMANDS: 78 | globals()[userCmd](cmd) 79 | else: 80 | # error 81 | msg = "Command not found. Try help command for documentation" 82 | throwError(msg) 83 | 84 | 85 | # ================================================== 86 | # =========== BLOCKSHELL COMMAND METHODS =========== 87 | # ================================================== 88 | def dotx(cmd): 89 | """ 90 | Do Transaction - Method to perform new transaction on blockchain. 91 | """ 92 | txData = cmd.split("dotx ")[-1] 93 | if "{" in txData: 94 | txData = json.loads(txData) 95 | print "Doing transaction..." 96 | coin.addBlock(Block(data=txData)) 97 | 98 | def allblocks(cmd): 99 | """ 100 | Method to list all mined blocks. 101 | """ 102 | print "" 103 | for eachBlock in coin.chain: 104 | print eachBlock.hash 105 | print "" 106 | 107 | def getblock(cmd): 108 | """ 109 | Method to fetch the details of block for given hash. 110 | """ 111 | blockHash = cmd.split(" ")[-1] 112 | for eachBlock in coin.chain: 113 | if eachBlock.hash == blockHash: 114 | print "" 115 | print eachBlock.__dict__ 116 | print "" 117 | 118 | def help(cmd): 119 | """ 120 | Method to display supported commands in Blockshell 121 | """ 122 | print "Commands:" 123 | print " dotx Create new transaction" 124 | print " allblocks Fetch all mined blocks in blockchain" 125 | print " getblock Fetch information about particular block" 126 | 127 | def throwError(msg): 128 | """ 129 | Method to throw an error from Blockshell. 130 | """ 131 | print "Error : " + msg 132 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | name="blockshell", 5 | version='0.1', 6 | author = "Daxeel Soni", 7 | author_email = "daxeelsoni44@gmail.com", 8 | url = "https://daxeel.github.io", 9 | description = ("A command line utility for learning Blockchain concepts."), 10 | py_modules=['bscli'], 11 | install_requires=[ 12 | 'Click', 13 | 'colorama', 14 | 'flask' 15 | ], 16 | entry_points=''' 17 | [console_scripts] 18 | blockshell=bscli:cli 19 | ''', 20 | ) 21 | -------------------------------------------------------------------------------- /templates/blockdata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Blockshell | Block Data 9 | 10 | 11 | 12 | 32 | 33 | 34 | 35 | 53 | 54 |
55 |
56 |
57 |

{{data['hash']}}

58 |
59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 |
Height{{data['index']}}
Timestamp{{data['timestamp']}}
Data{{data['data']}}
Hash{{data['hash']}}
Previous Block Hash{{data['previousHash']}}
Nonce{{data['nonce']}}
85 |

86 |

87 |
88 |
89 |
90 | Card image cap 91 |
92 |
About Project
93 |

Project BlockShell is created by with a vision to teach blockchain concepts to students and programmers.

94 | Contact Creator 95 |
96 |
97 |
98 |
99 |
100 | 101 | 129 | 132 | 133 | 134 | 135 | 136 | 137 | -------------------------------------------------------------------------------- /templates/blocks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Blockshell | All Blocks 9 | 10 | 11 | 12 | 32 | 33 | 34 | 35 | 53 | 54 |
55 |
56 |
57 |

Latest Blocks

58 | {% for item in data -%} 59 | 62 | {%- endfor %} 63 |

64 |

65 |
66 |
67 |
68 | Card image cap 69 |
70 |
About Project
71 |

Project BlockShell is created by with a vision to teach blockchain concepts to students and programmers.

72 | Contact Creator 73 |
74 |
75 |
76 |
77 |
78 | 79 | 107 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /templates/guide.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Blockshell | All Blocks 9 | 10 | 11 | 12 | 37 | 38 | 39 | 40 | 58 | 59 |
60 |
61 |
62 | 63 |

🏁 Introduction

64 |

Blockshell works on blockchain concepts and it creates a tiny blockchain in your local system. So, you will actually learn the concepts like blocks, mining, hashing, proof of work and lot more.

65 |

So, with blockshell you will be creating blocks with simple commands and rest of the tasks will be handled by Blockshell. In this wiki I will try to explain how Blockshell works behind every commands and how it is executing blockchain.

66 |

Let's get start!

67 |

🆕 Initialize New Blockchain

68 |

First we will initialize the new blockchain with following command in blockshell CLI.

69 |

[BLOCKSHELL] $ blockshell init --difficulty 3

70 |

Above command initializes new blockchain and creates chain.txt in your working directory where our blockchain data will be stored. You can compare this chain.txt file as real world blockchain's ledger.

71 |

--difficulty number indicates the difficulty level for blockchain's proof of work. More the number, more time will be taken to mine new block in our blockchain.

72 |

In our blockchain we have Initial Zeros Proof of Work algorithm. So, when we want to mine new block, our PoW will look for the hash that has the initial 3 characters are zeros(0) as right now our blockchain's difficulty level is set to 3 at the time of initialization.

73 |

Eg. hash

74 |

0002fdd96ffec46277a753fa983773599c816dcf100c956afae0a4853fd1ce32

75 |

⛏️ Mine First Block

76 |

Let's store some data and Mine very first block of our blockchain by doing PoW.

77 |

[BlockShell] $ dotx hello blockchain

78 |

Blockshell comes with build-in command dotx which is used to create a new transaction and this will mine new block with given data (eg. hello blockchain)

79 |

Output

80 |

[Status] Mining block (1) with PoW ...
81 | [ Info ] Time Elapsed : 0.0164740085602 seconds.
82 | [ Info ] Mined Hash : 000eea381e45c9f6c1c330cf991b5b1e7d15f739da3894b703e412881b2c2edd 83 |

84 |

Mining this block will depend on the difficulty level of the blockchain. Right now difficulty is of 3 and thats why our block mined in less than a second. After mining action, we received hash of that block with 3 initials as zero as difficulty is 3.

85 |

📦 Genesis Blocks

86 |

First block in blockchain is known as Genesis block and which is created manually at the time of blockchain development. In our case, creation of this genesis block is handled by Blockshell. When we initialized the blockchain, it also created genesis block. Lets check this out.

87 |

🕸️ Explore Blockchain

88 |

Now, we have 2 blocks in our blockchain. First is genesis block and other we created in previous step and that contains data hello blockchain

89 |

List all blocks in blockchain with following command

90 |

[BlockShell] $ allblocks

91 |

This lists hashes of all the blocks. 92 | Output 93 |

94 |

338a2d1ac1b8135283ae19a304b2b426b69b9caba7ef462f246fc577a0297230 95 | 000eea381e45c9f6c1c330cf991b5b1e7d15f739da3894b703e412881b2c2edd 96 |

97 |

ℹ️ View Block Data

98 |

Let's check what's inside each block. For this Blockshell has getblock command.

99 |

Here, 338a2d1ac1b8135283ae19a304b2b426b69b9caba7ef462f246fc577a0297230 is genesis block. Let's look inside our genesis block

100 |

[BlockShell] $ getblock 338a2d1ac1b8135283ae19a304b2b426b69b9caba7ef462f246fc577a0297230

101 |

Output

102 |

{ 103 | 'nonce': 0, 104 | 'index': 0, 105 | 'hash': '338a2d1ac1b8135283ae19a304b2b426b69b9caba7ef462f246fc577a0297230', 106 | 'previousHash': '', 107 | 'timestamp': '2018-01-27 20:13:44.835930', 108 | 'data': 'Genesis Block' 109 | } 110 |

111 |

Similarly, let's check what's inside our own created block.

112 |

[BlockShell] $ getblock 000eea381e45c9f6c1c330cf991b5b1e7d15f739da3894b703e412881b2c2edd

113 |

Output

114 |

115 | 

{ 116 | 'nonce': 1959, 117 | 'index': 1, 118 | 'hash': '000eea381e45c9f6c1c330cf991b5b1e7d15f739da3894b703e412881b2c2edd', 119 | 'previousHash': '338a2d1ac1b8135283ae19a304b2b426b69b9caba7ef462f246fc577a0297230', 120 | 'timestamp': '2018-01-27 20:15:01.515716', 121 | 'data': 'hello blockchain' 122 | } 123 |

124 |

🌐 Launch Blockshell Web

125 |

126 |

Blockshell comes with built-in Blockchain web explorer. You can search blocks and data in your blockchain from your web browser.

127 |

Open new terminal, go to cloned Blockshell directory and run web.py python script.

128 |

python web.py

129 |

Go to localhost 127.0.0.1:5000/allblocks in browser and give it a shot!

130 |
131 |
132 |
133 | Card image cap 134 |
135 |
About Project
136 |

Project BlockShell is created by with a vision to teach blockchain concepts to students and programmers.

137 | Contact Creator 138 |
139 |
140 |
141 |
142 |
143 | 144 | 172 | 175 | 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /web.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # ================================================== 3 | # ==================== META DATA =================== 4 | # ================================================== 5 | __author__ = "Daxeel Soni" 6 | __url__ = "https://daxeel.github.io" 7 | __email__ = "daxeelsoni44@gmail.com" 8 | __license__ = "MIT" 9 | __version__ = "0.1" 10 | __maintainer__ = "Daxeel Soni" 11 | 12 | # ================================================== 13 | # ================= IMPORT MODULES ================= 14 | # ================================================== 15 | from flask import Flask, render_template, jsonify 16 | import json 17 | 18 | # Init flask app 19 | app = Flask(__name__) 20 | 21 | @app.route('/') 22 | def index(): 23 | return render_template('guide.html') 24 | 25 | @app.route('/allblocks') 26 | def mined_blocks(): 27 | """ 28 | Endpoint to list all mined blocks. 29 | """ 30 | f = open("chain.txt", "r") 31 | data = json.loads(f.read()) 32 | f.close() 33 | return render_template('blocks.html', data=data) 34 | 35 | @app.route('/block/') 36 | def block(hash): 37 | """ 38 | Endpoint which shows all the data for given block hash. 39 | """ 40 | f = open("chain.txt", "r") 41 | data = json.loads(f.read()) 42 | f.close() 43 | for eachBlock in data: 44 | if eachBlock['hash'] == hash: 45 | return render_template('blockdata.html', data=eachBlock) 46 | 47 | # Run flask app 48 | if __name__ == '__main__': 49 | app.run(debug=True) 50 | --------------------------------------------------------------------------------