-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
64 lines (57 loc) · 1.42 KB
/
app.py
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
from flask import *
from random import randint
from takevalues import *
from gpsvalues import *
import os
import requests
app = Flask(__name__)
lq=0
@app.route("/")
def hello():
return "enter / sensors"
@app.route("/<string:c>/<string:b>")
def portt(c,b):
print c+"/"+b
global opened_port
opened_port = sensor("/"+c+"/"+b)
global gpsData
gpsData = gps()
return render_template('web.html', **locals())
@app.route("/sensors")
def sensors():
score = randint(0,10)
return render_template('web.html', **locals())
@app.route("/private")
def private():
text = request.args.get('jsdata')
if text=="1":
q = opened_port.takeValue()
print "1 "+str(q)
return render_template('ultrasonic.html', val=q)
if text=="2":
q = opened_port.takeUltrasonicValue2()
print "2 "+str(q)
return render_template('ultrasonic2.html', val=q)
if text[0]=="3":
print("Forward")
q = opened_port.sendMotor("3")
return render_template('m.html', val=q)
if text[0]=="4":
print("Stop")
q = opened_port.sendMotor("4")
return render_template('m.html', val=q)
if text[0]=="5":
print("Back")
q = opened_port.sendMotor("5")
return render_template('m.html', val=q)
if text[0]=="6":
print("GPSLat")
q = gpsData.gpsvaluesLat()
return render_template('m.html', val=q)
if text[0]=="7":
print("GPSLon")
q = gpsData.gpsvaluesLon()
return render_template('m.html', val=q)
if __name__ == "__main__":
app.debug=True
app.run(host='0.0.0.0')