diff --git a/app.py b/app.py index a5eb5d1..4ae803b 100644 --- a/app.py +++ b/app.py @@ -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)