forked from brmlab/brmbar-github
process codes in different ways
This commit is contained in:
parent
bd828a71e8
commit
0b488c469c
1 changed files with 13 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
|
from re import match
|
||||||
|
|
||||||
app = Flask('BrmBar')
|
app = Flask('BrmBar')
|
||||||
|
|
||||||
|
@ -10,7 +11,17 @@ def index():
|
||||||
|
|
||||||
@app.route('/code/<code>')
|
@app.route('/code/<code>')
|
||||||
def code(code):
|
def code(code):
|
||||||
return 'CODE "%s" received' % 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/')
|
@app.route('/admin/')
|
||||||
def admin():
|
def admin():
|
||||||
|
@ -25,4 +36,4 @@ def stats():
|
||||||
return render_template('stats.html')
|
return render_template('stats.html')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run()
|
app.run(port = 45678)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue