Skip to content
Advertisement

How to recalculate data from table in flask/python?

I want to show df in my app, im using flask to do it. But how can i make the table editable and calculated sum value by using button?

I couldn’t found good and easy way to edit that html table, and somehow send it to backend to recalculate.

Most tips i found abuot editables tables involve data from sql and model. I’m new to web apps, so js/html/css are a nightmere for me right now.

JavaScript
JavaScript

Advertisement

Answer

You can convert your data to a matrix to present it on table with inputs. And when you press the button you grab the data from the table and make an AJAX request to send the data in JSON format to another route and recalculate the sum.

After updating the data you just need to reload the page to see the changes.

You can use a transpose function to switch rows and columns.

main.py

JavaScript

index.html

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement