I am working on a song playing project and got stuck. Is there a way of passing a variable from php to python. I am working on a wordpress website and in some parts I used Python code and used php plugin to get the code working on that website. But here is the thing because I constantly need to copy the script and make new versions of it because I have to specify the path to the song and then insert the plugin into the website. So I was wondering if there is a way in which I could add this path to the python script trough php (meaning that I vould insert the path in php code instead of python)?
This is my plugin:
<?php # -*- coding: utf-8 -*-
/* Plugin Name: Python embedded */
add_shortcode( 'python', 'embed_python' );
function embed_python( $attributes )
{
$data = shortcode_atts(
[
'file' => 'hello.py'
],
$attributes
);
$handle = popen( __DIR__ . '/' . $data['file'], 'r' );
$read = '';
while ( ! feof( $handle ) )
{
$read .= fread( $handle, 2096 );
}
pclose( $handle );
return $read;
}
Is this even possible? Any ideas?