basic comms to raspberry pi w/confirmation

This commit is contained in:
FluffyCube9343 2022-11-12 15:34:19 -05:00
parent a372b0fd9b
commit 8b0248320d
3 changed files with 36 additions and 9 deletions

18
app.py
View File

@ -1,6 +1,6 @@
# app.py
from flask import Flask, render_template
from flask import Flask, render_template, request
from flask_assets import Bundle, Environment
app = Flask(__name__)
@ -16,6 +16,22 @@ css.build()
def homepage():
return 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,21 @@
class="img-part"
/>
<p class="measure">360</p>
<label for="fname">Input</label>
<input
class="inputbox"
type="text"
id="fname"
name="fname"
/>
<button class="button">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>