-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
43 lines (34 loc) · 1.08 KB
/
server.py
File metadata and controls
43 lines (34 loc) · 1.08 KB
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
from flask import Flask, request, json
import logging
import sys
import timer
#from timer import stopCountDown
logging.basicConfig(level=logging.DEBUG)
app = Flask(__name__)
@app.route('/')
def api_pitimer():
return 'Hello World'
@app.route('/stop')
def api_stop():
timer.stopCountDown()
return 'stopping'
@app.route('/timer', methods = ['POST'])
def api_timer():
logging.basicConfig(level=logging.DEBUG)
logging.info('HEllo')
logging.info('Data=' + request.data)
logging.info(request.json["minutes"])
timer.countDown(int(request.json["minutes"]))
return 'List of articles'
if __name__ == '__main__':
pitimer = logging.getLogger("flask.app")
pitimer.setLevel(logging.WARN)
adaLogger = logging.getLogger("Adafruit_I2C")
adaLogger.setLevel(logging.WARN)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.WARN)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
pitimer.addHandler(ch)
#logging.basicConfig(stream=sys.stdout)
app.run(host='0.0.0.0')