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)
|
@ -1 +1,2 @@
|
|||||||
CHIP-IO
|
CHIP-IO
|
||||||
|
flask
|
@ -14,7 +14,3 @@ def run(pin: str):
|
|||||||
print("[Door] Unlocked!")
|
print("[Door] Unlocked!")
|
||||||
|
|
||||||
GPIO.cleanup(pin)
|
GPIO.cleanup(pin)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
run("XIO-P7")
|
|
||||||
|
Reference in New Issue
Block a user