diff --git a/brmbar3/README.md b/brmbar3/README.md index 0bf93ca..b113083 100644 --- a/brmbar3/README.md +++ b/brmbar3/README.md @@ -53,6 +53,7 @@ These UIs are provided: advanced functionality like inventory revision that is too tedious to implement in the Qt4 GUI and only the brmbar admins are expected to do these tasks. +* **brmbar-web**: A simple read-only web interface to the stock list. TODO ---- diff --git a/brmbar3/brmbar-web.py b/brmbar3/brmbar-web.py new file mode 100755 index 0000000..dd54a5e --- /dev/null +++ b/brmbar3/brmbar-web.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +import sys + +from brmbar import Database + +import brmbar + +from flask import * +app = Flask(__name__) +#app.debug = True + +@app.route('/stock') +def stock(): + # TODO: Use a fancy template. + # FIXME: XSS protection. + response = '' + for a in shop.account_list("inventory"): + response += '' % (a.id, a.name, a.balance()) + response += '
IdItem NameBal.
%d%s%d
' + return response + + +db = Database.Database("dbname=brmbar") +shop = brmbar.Shop.new_with_defaults(db) +currency = shop.currency + +if __name__ == '__main__': + app.run()