diff --git a/app/routes.py b/app/routes.py index 0b5941f..11279dc 100644 --- a/app/routes.py +++ b/app/routes.py @@ -1,5 +1,5 @@ from flask import render_template -from flask import render_template, flash, redirect, url_for +from flask import render_template, flash, redirect, url_for, request from app import app from app.forms import SearchForm, BlankForm import sqlite3 @@ -29,9 +29,10 @@ def index(): c.execute('SELECT address,SUM(transferBalance) FROM transactiontable GROUP BY address') balanceTable = c.fetchall() conn.close() - return render_template('test.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable) + return render_template('index.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable) if blankform.validate_on_submit(): + return "str" flash('Balance requested for address {}'.format(form.address.data)) conn = sqlite3.connect(dblocation) c = conn.cursor() @@ -42,6 +43,23 @@ def index(): c.execute('SELECT address,SUM(transferBalance) FROM transactiontable GROUP BY address') balanceTable = c.fetchall() conn.close() - return render_template('test.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable) + return render_template('index.html', form=form, blankform=blankform, balance=balance, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable) - return render_template('index.html', form=form, blankform=blankform, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable) \ No newline at end of file + return render_template('index.html', form=form, blankform=blankform, transactionHistoryTable=transactionHistoryTable, balanceTable=balanceTable) + +@app.route('/transactions', methods=['GET', 'POST']) +def transactions(): + address = request.args.get('address') + if address is not None: + conn = sqlite3.connect(dblocation) + c = conn.cursor() + c.execute('SELECT * FROM transactionHistory WHERE fromAddress="{}" OR toAddress="{}" ORDER BY id DESC'.format(address,address)) + transactionHistoryTable = c.fetchall() + conn.close() + return render_template('transactions.html', transactionHistoryTable=transactionHistoryTable) + conn = sqlite3.connect(dblocation) + c = conn.cursor() + c.execute('SELECT * FROM transactionHistory ORDER BY id DESC') + transactionHistoryTable = c.fetchall() + conn.close() + return render_template('transactions.html', transactionHistoryTable=transactionHistoryTable) diff --git a/app/templates/base.html b/app/templates/base.html index 1c7c118..512a875 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -36,16 +36,13 @@ - RMT Explorer + RMT Explorer diff --git a/app/templates/index.html b/app/templates/index.html index 796b572..a7602c7 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -33,7 +33,7 @@ {% if balance %}

-

Balance {{balance}} RMT

+

Balance - {{balance}} RMTRelated transactions

{% endif %} @@ -85,10 +85,11 @@
- View all +
diff --git a/app/templates/transactions.html b/app/templates/transactions.html index 7458173..a7e8f03 100644 --- a/app/templates/transactions.html +++ b/app/templates/transactions.html @@ -18,36 +18,13 @@
-

RMT Balance

-
-
-
-
-
- - {{ form.hidden_tag() }} - {{ form.address(class="form-control", placeholder="Enter FLO address", length=100) }} - {% for error in form.address.errors %} - [{{ error }}] - {% endfor %} - {% if balance %} -
-
-

Balance {{balance}} RMT

-
- {% endif %} -
-
-
+

Transactions

-
-

Latest Transactions

-
@@ -84,41 +61,6 @@ {% endfor %}
-
- - View all - -
-
-
-
-
- -
-
-
-

Balances

-
-
-
- - - - - - - {% for item in balanceTable %} - - - - - {% endfor %} - -
- Address - - Balance -
{{item[0]}}{{item[1]}}