Using DataTables with Python - python-3.x

I'm a beginner at website programming and want to understand some basics.
I've created a Python 3 script which fetches some data from a website and makes some calculations. Result is then about 20 rows with 7 columns.
What is the easiest way to make them available on my website? When refreshing my website, the Python script should fetch the data from the 3rd party website and this data should then be displayed in a simple table with sorting option.
I've discovered the jQuery plugin DataTables with Ajax JSON source. I would create a PHP script which executes the Python script which writes data to a DB like MariaDB. PHP then creates a JSON for Ajax.
Is this the right way or are there easier ways? Maybe using a framework etc.?
Thanks!

It's easier than I thought, there is no need for PHP and MariaDB.
When using nginx, you need uswgi and uswgi-plugin-cgi to let nginx know that the Python script is a script and not data. Point to the Python script in the Ajax parameter of the DataTable JS code, make it executable and print the array with JSON function in the Python script, and include cgi/json header strings. The array should look like that in the example of Datatables Website (Ajax source).
It's all running in the memory now.

Related

DataTables export to excel

I'm currently working on a project (developed using laravel, php, javascript, jquery, html), containing a large amount of data, so I'm using DataTables to display them with serverside set to true. What I'm trying to figure out is how to export the complete table to an excel file - right now it only saves one page (the one being shown at that very moment ) - using the Button extention.
I've been reading about it for a while now but still can't figure out a way to do this. I understand that, since serverside is set to true,
the only rows that exist on the client-side are those shown in the table at any one time.
But how can I get the complete table? Any help would be appreciated!
UPDATE:
So I create the excel file with the data I want in the backend, using PHPExcel, but now the problem is that it is saved server-side, while I wanna make it downloadable (client-side). From what I've been reading, I must add the appropriate headers to do so, but nothing I've tried works. Using
this, I managed to output the data of the excel in the screen, but it just shows gibberish... I should probably also mention that I'm new at this!

How to log in and auto fill values into a 'drupal form' from an 'excel file'?

So, there is this website where I have to log in and insert values in the add content->person roles and I have to take values from an excel file. I tried entering the values in the database directly but got nowhere. The database is too randomly generated.
I want to know- how to go by this problem? I think python would be the best way but I am more comfortable with java. The images bellow will help understand the situation better-
The log in from:
The form to be filled:
Try using feeds module:
https://www.drupal.org/project/feeds
Install it on you site first of course. Or look for some similar import module. Maybe this one:
https://www.drupal.org/project/datasources
If nothing succeeds then try making import script on your own. You have to parse document (would be much easier to open it from excel and export as CSV if possible http://php.net/manual/en/function.fgetcsv.php) and have some loop to write content into Drupal system. Use Drupal's functions for that, do not directly write to database. It's not hard as it looks like:
https://www.drupal.org/node/1388922

live search on webpage without refreshing it

I know you can achieve it with php, mysql and ajax, but it reads the data from a database file, right ?
I'm thinking about how I should make small page with that. Should i place all my text, titles in the database or is there a way to do that inside of html structure ?
Don't put all the data inside the document, that would eventually make the website slow.
Store the data in a database and download it when typing in the search field. You can either send a request every n seconds using AJAX, or download and store all the data in f.e. localStorage and call that using AJAX.

How to interface a Chrome extension with another program?

I want to observe mutations of the DOM on a dynamic webpage, specifically the value of one div.I don't want to repeatedly download the webpage and search for this value, as it seems inefficient. I would like to display this value inside another program. What are my options to communicate with another program from inside a Chrome extension ?
One idea that came to my mind is this one: install a local Web server and grab POST values sent to PHP script from the Chrome extension. Then I could write to the filesystem, and observe a specific file.
Is there another way to do this ?

Exporting data from JSon

We are creating a map application that has a list view of the resultant set using JSON and jQuery and presenting the result to the user. How can we give the user the ability to download the result as an Excel file/CSV file?
Assuming a web application...
Convert JSON to CSV
Present It as an HTTP response.
You mentioned JSON and jQuery. I assume this is being used on the client side? There are a number of utilities for making the JSON-to-CSV conversion depending on the language you would want to use. Here are some examples.
Javascript/jQuery
PHP
Python

Resources