brmbar-github/server/brmbar-server
2011-06-13 16:36:04 +02:00

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)