I am new to python and Flask. I have a Flask web application with a button. When I click on the button, I would like to execute a python method, not a Javascript method. How can i do this?
I saw examples with python where it redirects me to a new page using a form tag like
<form action="/newPage" method="post">
but I don’t want him to redirect me to a new page. I just want it to execute the python method.
I am doing this for a Raspberry Pi robot . When I press the forward button, I want it to launch a method for turning the wheels forward.
HTML Code Button ( index.html )
<button name="forwardBtn" onclick="move_forward()">Forward</button>
simple app.py code is the move_forward () method located here
from flask import Flask, render_template, Response, request, redirect, url_for
app = Flask(__name__)
@app.route("/")
def index():
return render_template('index.html');
def move_forward():
print("Moving Forward...")
Stackoverflow, , , , . - Python , .
, :
- Python Flask
- python
- Python ?