mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 05:14:00 +02:00
39 lines
859 B
Python
Executable file
39 lines
859 B
Python
Executable file
#!/usr/bin/python
|
|
|
|
from flask import Flask, render_template
|
|
from re import match
|
|
|
|
app = Flask('BrmBar')
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return render_template('index.html')
|
|
|
|
@app.route('/code/<code>')
|
|
def code(code):
|
|
if code == 'RST':
|
|
return 'RESET received'
|
|
if match('^\$[0-9]+$', code):
|
|
amount = int(code[1:])
|
|
return 'CREDIT %d received' % amount
|
|
if match('^U[0-9]{4}$', code):
|
|
userid = int(code[1:])
|
|
return 'USER %s received' % userid
|
|
if match('^[0-9]+$', code):
|
|
return 'ITEM %s received' % code
|
|
abort(400)
|
|
|
|
@app.route('/admin/')
|
|
def admin():
|
|
return render_template('admin.html')
|
|
|
|
@app.route('/log/')
|
|
def log():
|
|
return render_template('log.html')
|
|
|
|
@app.route('/stats/')
|
|
def stats():
|
|
return render_template('stats.html')
|
|
|
|
if __name__ == '__main__':
|
|
app.run(port = 45678)
|