Created
May 27, 2018 06:06
-
-
Save khssnv/4afc185c94379465e2fdaa4ee95be8bd to your computer and use it in GitHub Desktop.
Ethereum Ropsten last block number from Infura to HTTP at localhost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 | |
from web3 import Web3 | |
from flask import Flask, request | |
from flask_restful import Resource, Api | |
from flask.json import jsonify | |
app = Flask(__name__) | |
api = Api(app) | |
with open('../secrets/infura_api.key', 'r') as f: | |
apikey = f.readline() | |
w3 = Web3(Web3.HTTPProvider('https://ropsten.infura.io/' + apikey)) | |
class BlockNumber(Resource): | |
def get(self): | |
return jsonify({'blockNumber': w3.eth.blockNumber}) | |
api.add_resource(BlockNumber, '/blockNumber') | |
if __name__ == '__main__': | |
app.run(port='5002') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment