admin管理员组文章数量:1405137
I have tried implementing the steps mentioned in this post: Previous Post
However, there is not output. it appears that Python script is not executing at all. Just to mention here that I have worked around with Hosting provider to enable popen, pclose, proc_open, and proc_close.
Here is the code in the wordpress plugin:
<?php # -*- coding: utf-8 -*-
/* Plugin Name: gm-python */
add_shortcode( 'python', 'embed_python' );
function embed_python( $attributes )
{
$data = shortcode_atts(
[
'file' => 'hello.py'
],
$attributes
);
if($_SERVER['REQUEST_METHOD'] === 'GET'){
$handle = popen( __DIR__ . '/' . $data['file'] . '2>&1', 'r' );
$read = '';
if($read){
while (!feof($handle))
{
$read.= fread($handle, 2096);
}
}
}
pclose($handle);
return $read;
}
here is what is in the python script:
#!/usr/bin/env python
print('Hello World')
I have installed python outside of the websites as well.
Can anybody help to find the correct way to configure the path for python execution through wordpress plugin?
本文标签: pluginsPoint Python path in Wordpress
版权声明:本文标题:plugins - Point Python path in Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744885090a2630437.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论