if(invalid){don't send;}

This commit is contained in:
FluffyCube9343 2022-11-12 16:03:23 -05:00
parent 5fe0a0ef59
commit 91b6386172

30
app.py
View File

@ -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)