How to load 1 million rows of record in html with python and flask as backend [closed]

I am trying to display about 1 million records in a DataTable but obviously, it is not going to go through with normal loading, I would need server-side DataTable, I tried to go through the example that they have given, but it is given in PHP and I am trying to code in python, I also tried to google about the issue but I was not able to find a solution for this. One of the main things is that the table headers or column headers that I am using are also dynamic, the data is based on some drop-down options on the webpage, and according to that, I am querying my DB. While returning the records I am returning column headers as the first row (data[0]) and then all the data in json.

Source: Python Questions