Refactor ChipUnlocker

This commit is contained in:
2019-10-02 15:26:09 +08:00
parent f435e8d9e0
commit 99d850a305
3 changed files with 23 additions and 20 deletions

8
app.py
View File

@ -1,13 +1,13 @@
import os
from flask import Flask, request, abort, jsonify
import unlocker
from chip_unlocker import ChipUnlocker
PORT = os.environ.get('PORT') or 5000
CODE = os.environ.get('CODE') or '8787'
UNLOCKER_PIN = os.environ.get('UNLOCKER_PIN') or 'XIO-P7'
UNLOCK_PIN = os.environ.get('UNLOCK_PIN') or 'XIO-P7'
app = Flask(__name__)
unlocker = ChipUnlocker(UNLOCK_PIN)
@app.route('/')
@ -22,7 +22,7 @@ def unlock():
code = request.args.get('code')
if (code == CODE):
unlocker.run(UNLOCKER_PIN)
unlocker.unlock()
return "OK"
else:
abort(404)