1

I am new to python Notebook and I am having problem with displaying the output to the webpage. It always open a popup window instead of displaying the output in Html form. Is there a way to put a code in my site and let the python language interpret my code and display the output as html when the page is loaded? or image if it is a graph?. See the sample image below.

[sample screenshot from a website][1]

Currently my code to call python is

 <?php 

  $command = escapeshellcmd('python C:\Users\dondell\Downloads\a.py');
  $output = shell_exec($command);
  echo $output;

 ?>

This code will print number output to html directly but if the output is image. it will not display but a popup window appear instead.

ssoler
  • 3,886
  • 4
  • 27
  • 31
Dondell Batac
  • 113
  • 10
  • Possible duplicate of [How to make IPython notebook matplotlib plot inline](http://stackoverflow.com/questions/19410042/how-to-make-ipython-notebook-matplotlib-plot-inline) – rakslice May 12 '16 at 04:01
  • No it is not duplicate. I want to show it on my own website not using jupyter at all. I want like this . He can run the code directly to his website. https://www.datacamp.com/community/tutorials/the-importance-of-preprocessing-in-data-science-and-the-machine-learning-pipeline-ii-centering-scaling-and-logistic-regression# – Dondell Batac May 12 '16 at 04:19
  • How about saving the image to local folder and return its path from python file so that you can use `img` tag and show the image? – Pant May 12 '16 at 05:25
  • I want to run it like Jupyter but inside my web page. – Dondell Batac May 12 '16 at 06:28
  • The window opening might be a matplotlib plot. If you're trying to do plotting, your Python code will need to save it to a file which your PHP can then serve. – Thomas K May 12 '16 at 17:29
  • @DondellBatac Looking at the source code for that tutorial page you linked, it appears to be using something called datacamp-light to embed a jupyter-like notebook. I found some instructions to get started with it in the github readme: https://github.com/datacamp/datacamp-light which may help. – rakslice May 12 '16 at 17:49
  • @rakslice Your answer is so far the best. But it is not capable of graph presentation like that of jupyther right?. But thanks anyway man. – Dondell Batac May 13 '16 at 01:10

1 Answers1

0

I believe that the best you can do is using NBViewer. This renders the notebook but you cannot execute it, I believe that executing it is not an easy task