I am beginner in web development. I have an button Using HTML and CSS. Like this,
.button_1 {
position: relative;
padding: 20 px;
top: 95px;
left: 45px;
}
.button_1 input {
display: none;
}
.button_1_span {
width: 100px;
height: 40px;
background: red;
display: block;
overflow: hidden;
cursor: pointer;
transition: 0.4s;
border-radius: 15px;
}
.button_1_span:before {
content: '';
width: 32px;
height: 32px;
left: 4px;
bottom: -36px;
background: black;
position: absolute;
border-radius: 15px;
}
.button_1 input:checked+.button_1_span {
background: green;
}
.button_1 input:checked+.button_1_span:before {
left: 64px;
}
<label class="button_1">
<input type="checkbox">
<span class="button_1_span"></span>
</label>
In this button there is two position red and green. Now, I want to call two python function using flask depends on red and green position of my button
. Sample flask code is given here,
app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def index():
return render_template('button.html')
@app.route('/at_red_position_button/')
def my_detection():
print ('From red_position_button')
return 'Red.'
@app.route('/at_green_position_button/')
def my_reading():
print ('From Green_position_button')
return 'Green.'
if __name__ == '__main__':
app.run(debug=True)
As, I am beginner I will appreciate any kinds of help. Thanks in advance.