Changed index endpoint
This commit is contained in:
parent
bed0ceac7e
commit
a5f5322a84
31
web.py
31
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/<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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue