Created
July 23, 2017 01:32
-
-
Save aunyks/3f4372b2d01d8584ae2ccd8bab62c520 to your computer and use it in GitHub Desktop.
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
from flask import Flask | |
from flask import request | |
node = Flask(__name__) | |
# Store the transactions that | |
# this node has in a list | |
this_nodes_transactions = [] | |
@node.route('/txion', methods=['POST']) | |
def transaction(): | |
if request.method == 'POST': | |
# On each new POST request, | |
# we extract the transaction data | |
new_txion = request.get_json() | |
# Then we add the transaction to our list | |
this_nodes_transactions.append(new_txion) | |
# Because the transaction was successfully | |
# submitted, we log it to our console | |
print "New transaction" | |
print "FROM: {}".format(new_txion['from']) | |
print "TO: {}".format(new_txion['to']) | |
print "AMOUNT: {}\n".format(new_txion['amount']) | |
# Then we let the client know it worked out | |
return "Transaction submission successful\n" | |
node.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment