summaryrefslogtreecommitdiffstats
path: root/bitvend.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitvend.py')
-rw-r--r--bitvend.py49
1 files changed, 20 insertions, 29 deletions
diff --git a/bitvend.py b/bitvend.py
index 737e8b0..339114e 100644
--- a/bitvend.py
+++ b/bitvend.py
@@ -3,51 +3,39 @@ import threading
import flask
from flask_qrcode import QRcode
-from bitvend.mdb import CashlessMDBDevice
+from bitvend.mdb import BitvendCashlessMDBDevice
from bitvend.utils import to_local_currency, from_local_currency, format_btc, \
sat_to_btc
from bitvend.processor import PaymentProcessor
+from bitvend.models import db, Transaction
logging.basicConfig(level=logging.INFO)
-#from prometheus_client import start_http_server, Counter
-#start_http_server(8000)
+from prometheus_client import start_http_server
+start_http_server(8000)
-#coin_counter = Counter('coins_inserted', 'Number of coins inserted into machine')
-#purchase_counter = Counter('purchases', 'Number of purchases')
+app = flask.Flask(__name__)
+app.config.from_object('bitvend.default_settings')
-dev = CashlessMDBDevice()
-proc = PaymentProcessor(dev)
+db.init_app(app)
-app = flask.Flask(__name__)
QRcode(app)
-app.config['INPUT_ADDRESS'] = '12fkW5EBb3uBy1zD8pan4TcbabP5Fjato7'
-app.config['TEMPLATES_AUTO_RELOAD'] = True
-app.config['ITEMS'] = [
- {
- 'name': 'Club Mate',
- 'image': '/static/img/club-mate.png',
- 'value': 500,
- },
- {
- 'name': 'Arduino Pro Micro',
- 'image': '/static/img/promicro.png',
- 'value': 1600,
- },
-]
-'''
- {
- 'name': 'Arduino Pro Mini',
- 'image': '',
- 'value': 750,
- },
-'''
+dev = BitvendCashlessMDBDevice()
+dev.init_app(app)
+
+proc = PaymentProcessor(dev)
+proc.init_app(app)
+
@app.route('/')
def index():
return flask.render_template(
'index.html', items=app.config['ITEMS'])
+@app.route('/log')
+def log():
+ return flask.render_template(
+ 'log.html', transactions=Transaction.query.all())
@app.route('/begin/<int:amount>')
def begin_session(amount):
dev.begin_session(amount)
@@ -68,6 +56,9 @@ def ctx_utils():
}
if __name__ == "__main__":
+ with app.app_context():
+ db.create_all()
+
threading.Thread(target=app.run, kwargs={
'host': '0.0.0.0'
}, daemon=True).start()