I have this route in main.py:
@app.route('/')
def home():
def remove_book():
print('im here')
return render_template('index.html', books=Books.query.all(), rem_book=remove_book)
So, I try call the remove_book function in button of my index.html file:
<button class="btn btn-danger btn-sm" onclick={{rem_book}}>X</button>
And nothing is printed in terminal, whats wrong with my code?
I expected the 'im here' string printed on terminal
You can create a form in HTML and make a post route like this: index.html
app.py
I hope this solves your problem. But if you are making a function to change the DOM content(webpage), you need to learn JS.