Create web server
This commit is contained in:
25
app.py
Normal file
25
app.py
Normal file
@ -0,0 +1,25 @@
|
||||
import os
|
||||
from flask import Flask, request, abort
|
||||
|
||||
import unlocker
|
||||
|
||||
PORT = os.environ.get('PORT') or 5000
|
||||
CODE = os.environ.get('CODE') or '8787'
|
||||
UNLOCKER_PIN = os.environ.get('UNLOCKER_PIN') or 'XIO-P7'
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@app.route('/unlock')
|
||||
def root():
|
||||
code = request.args.get('code')
|
||||
|
||||
if (code == CODE):
|
||||
unlocker.run(UNLOCKER_PIN)
|
||||
return "OK"
|
||||
else:
|
||||
abort(404)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(port=PORT)
|
Reference in New Issue
Block a user