How to take real time input output from a python script on PHP
<p>I want to take input from user through a html form, process it through a python script and print the output on html page. The problem is the whole python script is executed each time, while I want the script to give real time output for each input. How can I manage to do this ? </p>

<p>Here is what I am doing so far.</p>

<pre><code>&lt;?php
    $vout='';
    if(isset($_POST['submit']))
    {
        $vin=$_POST['input_text'];
        $vout=exec('python bot.py '.$vin);
    }
?&gt;
&lt;form method="post"&gt;
&lt;label&gt;
    BotIn: &lt;input type="text" name="input_text"&gt;
&lt;/label&gt;
&lt;input type="submit" name="submit"&gt;
&lt;/form&gt;
&lt;/br&gt;&lt;/br&gt;
&lt;label&gt;
    &lt;p&gt;Bot: &lt;?=$vout?&gt;&lt;/p&gt;
&lt;/label&gt;
</code></pre>

<p>The best way to solve your problem will be running simple python app using, let's say, <a href="http://flask.pocoo.org" rel="nofollow">Flask</a> and hit to specific endpoint you'll make in it. Everything then could take place through localhost, if you'll set it on the same machine.</p>

php python