From a5f5322a8411d7b69d258ebafeed66eae3216c68 Mon Sep 17 00:00:00 2001 From: Daxeel Soni Date: Fri, 26 Jan 2018 10:37:46 +0530 Subject: [PATCH] Changed index endpoint --- web.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/web.py b/web.py index 5af2387..1bf2c48 100644 --- a/web.py +++ b/web.py @@ -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/') 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)