Merge pull request #1 from PotentiaRobotics/rpicommdev

basic comms to raspberry pi w/confirmation
This commit is contained in:
Vrishak Vemuri 2022-11-12 15:41:29 -05:00 committed by GitHub
commit 518899e07a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 8 deletions

16
app.py
View File

@ -27,6 +27,22 @@ def homepage():
return App.render(render_template("index.html"))
@app.route("/base.html", methods =["GET", "POST"])
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()
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)

View File

@ -213,3 +213,8 @@ a:link,
a:visited {
text-decoration: none;
}
.enter-angle {
display: flex;
flex-direction: row;
}

View File

@ -27,15 +27,23 @@
class="img-part"
/>
<p class="measure">360</p>
<label for="fname">Input</label>
<input
class="inputbox"
type="text"
id="userInput"
name="fname"
/>
<button class="button" onclick="server.printinput()">Enter</button>
<form
action='{{ url_for("sendData")}}'
class="enter-angle"
method="POST"
>
<label for="rot">Input</label>
<input
class="inputbox"
type="text"
id="rot"
name="rot"
/>
<input type="submit" value="Enter" />
</form>
<p class="units">Deg</p>
<select name="input" id="unit">
<option value="Position">Position</option>