To understand what actually is Flask in Python and how it use in my case I watched more than 7 Youtube video tutorial by Julian Nash in these topics:
.. but how I did it?
pip list. If a
new version is available you will receive notice about that. For upgrade pip - pip3 install --upgrade pippip3 install flaskcd command I go to the folder when I want to create and storage this project and create a new file.touch [filename].pypython3 -m venv [foldername],
then source env/bin/activate.
In tutorials what I watched (see above) it was done - I also did that without deep analyze why, but later my Fab Academy
mentor Kris explained that in this case it isn't necessary, virtual environment is useful when at the same time you work with
different Python version and packages and in some case it could be in conflict, but if you don't want uninstall packages, then
virtual environment is way how to avoid it. flask run command, but there is a big chance that you will be notified something like
WARNING: This is a development server. Do not use it in a production deployment. This means that in your interface will NOT be visible
debug information, just a message "Internal Server Error" and not always it helps developer to understand where the problem is.
To solve it try this command export FLASK_APP=[filename].py, then export FLASK_ENV=development
and again flask run.


$("#btnSet").click(function (e) {
var speedValue = $("#speed").val();
var angleValue = $("#angle").val();
var turnsValue = $("#turns").val();
var directionValue = $("#mydirection :selected").val();
alert(`Speed : ${speedValue} Angle : ${angleValue} Turns : ${turnsValue} Direction : ${directionValue}`);
$.ajax({
url:"/",
type: "POST",
data:{"Speed": speedValue,
"Angle": angleValue,
"Turns": turnsValue,
"Direction": directionValue
},
success: function(response){
console.log(response);
},
error: function (error){
console.log(e)
}
});
e.preventDefault();
})
methods=["GET", "POST"]




# Open grbl serial port
s = serial.Serial('/dev/tty.usbmodem142101',115200)
# Wake up grbl
s.write("\r\n\r\n".encode())
time.sleep(2) # Wait for grbl to initialize
s.flushInput() # Flush startup text in serial input
"$J=G21G91X"
and know that I plan the structure of the if..else statement.
@app.route("/", methods=["GET", "POST"])
def index():
gcode = "$J=G21G91X"
if request.method == "POST":
print(request.form)
directionReceived = request.form.get("Direction")
if directionReceived == "CCW" :
gcode = gcode + "-"
turning = request.form.get("Turns")
xValue = int(turning) * 40
gcode = gcode + str(xValue)
gcode = gcode + "F400\n"
print("gcode:" + gcode)
s.write(gcode.encode())
Message = {"Message":"Python says hello"}
return Message
return render_template("index.html")
pip3 install opencv pythonfrom cv2 import cv2python3 [filename].py not just python [filename].pycam = cv2.VideoCapture(1), but when with input device, then cam = cv2.VideoCapture(2)
from cv2 import cv2
cam = cv2.VideoCapture(2) #signature that camera starts work
cv2.namedWindow("Python Webcam Screenshot App")
img_counter = 0
while True:
ret,frame = cam.read()
if not ret:
print ("Something failed!")
break
cv2.imshow("test",frame)
k = cv2.waitKey(1)
if k%256 ==27:
print("Escape hit, closing the app")
break
elif k%256 == 32:
img_name = "opencv_frame_{}.png".format(img_counter)
cv2.imwrite(img_name,frame)
print("Screenshot taken")
img_counter+=1
cam.release()
cam.destroyAllWindows()
