forked from ericescobar/Chicken_Door
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoor.py
More file actions
50 lines (34 loc) · 956 Bytes
/
door.py
File metadata and controls
50 lines (34 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from flask import (
Blueprint, jsonify, flash, g, redirect, render_template, request, url_for
)
from Chicken_Door.door_setup import get_door
bp = Blueprint('door', __name__)
@bp.route('/')
def hello():
return "Hello, World! I'm a door!"
@bp.route('/status/')
def create():
door = get_door()
data = {"topSensor": "active",
"bottomSensor": "inactive"}
return jsonify(door.status())
@bp.route('/open/')
def open():
door = get_door()
return jsonify({"openStatus": door.open()})
@bp.route('/close/')
def close():
door = get_door()
return jsonify({"closeStatus": door.close()})
@bp.route('/up/')
def up():
door = get_door()
return jsonify({"upStatus": door.up(2)})
@bp.route('/up/<runTime>/')
def upTime(runTime):
door = get_door()
return jsonify({"upStatus": door.up(runTime)})
@bp.route('/down/')
def down():
door = get_door()
return jsonify({"downStatus": door.down(2)})