forked from brmlab/brmbar-github
brmbar-web: New trivial read-only UI
This commit is contained in:
parent
10d8a17723
commit
e6870f8b2a
2 changed files with 30 additions and 0 deletions
|
@ -53,6 +53,7 @@ These UIs are provided:
|
||||||
advanced functionality like inventory revision that is too tedious
|
advanced functionality like inventory revision that is too tedious
|
||||||
to implement in the Qt4 GUI and only the brmbar admins are expected
|
to implement in the Qt4 GUI and only the brmbar admins are expected
|
||||||
to do these tasks.
|
to do these tasks.
|
||||||
|
* **brmbar-web**: A simple read-only web interface to the stock list.
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
----
|
----
|
||||||
|
|
29
brmbar3/brmbar-web.py
Executable file
29
brmbar3/brmbar-web.py
Executable file
|
@ -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 = '<table border="1"><tr><th>Id</th><th>Item Name</th><th>Bal.</th></tr>'
|
||||||
|
for a in shop.account_list("inventory"):
|
||||||
|
response += '<tr><td>%d</td><td>%s</td><td>%d</td></tr>' % (a.id, a.name, a.balance())
|
||||||
|
response += '</table>'
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
db = Database.Database("dbname=brmbar")
|
||||||
|
shop = brmbar.Shop.new_with_defaults(db)
|
||||||
|
currency = shop.currency
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run()
|
Loading…
Add table
Add a link
Reference in a new issue