>180 not allowed hehe :P

This commit is contained in:
FluffyCube9343 2023-03-11 15:08:04 -05:00
parent 8644a6f085
commit f1ea7da8fe

11
app.py
View File

@ -35,24 +35,25 @@ def sendData():
rot = request.form.get("rot")
try:
rot = int(rot)
rot = int(rot)%360
rot = rot-360 if rot > 180 else rot
print("Activated")
import socket
s=socket.socket()
host="raspberrypi" #This is your Server IP!
port=2345
s.settimeout(5)
s.settimeout(10)
s.connect((host,port))
s.send(str(rot).encode())
rece=s.recv(1024)
print("Received",rece)
s.close()
rece = "Confirm Sent: "+rece.decode("ASCII")
return render_template("index.html", conf=rece)
return render_template("manual.html", conf=rece)
except ValueError:
return render_template("index.html", conf='Invalid Input "'+rot+'"')
return render_template("manual.html", conf='Invalid Input "'+rot+'"')
except:
return render_template("index.html", conf='Timeout: Unable to reach Pi')
return render_template("manual.html", conf='Timeout: Unable to reach Pi')
if __name__ == "__main__":
app.run(debug=True)