How to link a html button to a Python script -Flask
Hi! I'm new in Python and Flask. I'm trying to make a website where in a page is a modal made with Bootstrap. In this modal, the user should write a title , and then press a button for searching. I have a Python script which compute recommendation. The idea is : I don't know how to link the input from the modal to be the parameter for the python function, and then return the output of the function in the modal. This is the Python function: def authors_recommendations(title): idx = indices[title] sim_scores = list(enumerate(cosine_sim[idx])) sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True) sim_scores = sim_scores[1:21] book_indices = [i[0] for i in sim_scores] return titles.iloc[book_indices] print(authors_recommendations(title).head(20)) This is the modal: <div class="modal-body"> <form action="/cautare" method="POST"> <label for="titlu" class="col-form-label">Introdu titlul ultimei carti citite:</label> <input type="text" class="form-control" id="titlu" placeholder="Titlul_cartii"> <input type="hidden" id="tip"> <div id="raspuns"></div> </form> </div> <div class="modal-footer"> <!--The button for the searching should be here--> <button id="cautare" >Search</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> Thank you!