Repository navigation
Expand file tree
/
Copy pathflaskSeedSense.py
More file actions
67 lines (50 loc) · 1.47 KB
/
Copy pathflaskSeedSense.py
File metadata and controls
67 lines (50 loc) · 1.47 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from operator import truediv
from flask import Flask, jsonify, render_template, request
from connectSense import *
import sys
app = Flask(__name__, template_folder="templates")
global ip
global connected
ip = "172.19.61.109"
connected = False
currentData = 'OFF'
@app.route('/_stuff', methods = ['GET'])
def stuff():
#return jsonify(result = receiveData())
global connected
global currentData
if connected:
toReturn = receiveData(currentData)
currentData = toReturn
return jsonify(result = toReturn)
return jsonify(result = testData())
@app.route('/')
def first_function():
return render_template('index.html')
@app.route('/_connect', methods = ['GET'])
def connect():
global connected
print(f"before{connected}", file=sys.stdout)
try:
if connected == False:
connected = True
print(f"after{connected}", file = sys.stdout)
return jsonify(isconnect = 'true')
else:
return jsonify(isconnect = 'true')
except:
return jsonify(isconnect = 'false')
@app.route('/test')
def returnTest():
return jsonify(result = "hell")
@app.route('/displayData')
def displayData():
try:
connectESP32()
connected = True
except:
pass
return render_template('dataDisplay.html')
if __name__ == "__main__":
#app.run(host=ip, debug=True)
app.run(debug=True)