Changed index endpoint

This commit is contained in:
Daxeel Soni 2018-01-26 10:37:46 +05:30 committed by GitHub
parent bed0ceac7e
commit a5f5322a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 7 deletions

31
web.py
View File

@ -1,14 +1,28 @@
# -*- coding: utf-8 -*-
# ==================================================
# ==================== META DATA ===================
# ==================================================
__author__ = "Daxeel Soni"
__url__ = "https://daxeel.github.io"
__email__ = "daxeelsoni44@gmail.com"
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Daxeel Soni"
# ==================================================
# ================= IMPORT MODULES =================
# ==================================================
from flask import Flask, render_template, jsonify
import json
# Init flask app
app = Flask(__name__)
# Index endpoint
@app.route('/')
def hello_world():
return "Blockshell"
@app.route('/allblocks')
def blocks():
@app.route('/')
def mined_blocks():
"""
Endpoint to list all mined blocks.
"""
f = open("chain.txt", "r")
data = json.loads(f.read())
f.close()
@ -16,6 +30,9 @@ def blocks():
@app.route('/block/<hash>')
def block(hash):
"""
Endpoint which shows all the data for given block hash.
"""
f = open("chain.txt", "r")
data = json.loads(f.read())
f.close()
@ -23,6 +40,6 @@ def block(hash):
if eachBlock['hash'] == hash:
return render_template('blockdata.html', data=eachBlock)
# Run flask app
if __name__ == '__main__':
app.run(debug=True)