diff --git a/app.py b/app.py index e7236b4..e8e3467 100644 --- a/app.py +++ b/app.py @@ -20,20 +20,22 @@ def homepage(): def sendData(): rot = request.form.get("rot") - - print("Activated") - import socket - s=socket.socket() - host="raspberrypi" #This is your Server IP! - port=2345 - 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) - + try: + rot = int(rot) + print("Activated") + import socket + s=socket.socket() + host="raspberrypi" #This is your Server IP! + port=2345 + 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) + except ValueError: + return render_template("index.html", conf='Invalid Input "'+rot+'"') if __name__ == "__main__": app.run(debug=True)