0

I want to build a very simple web page running LOCALLY on my computer, displaying results from a Python script. I have tried using HTML and PHP but without any luck. Please bear in mind that I'm a complete newbie in web development.

Let's say I want to very simply print some text on the web page. This is what "helloworld.py" looks like:

print("hello world")

This is what helloworld.html looks like:

<html>
<body>
<?php
$message = exec('helloworld.py');
print_r($message);?>
</body>
</html>

However, when I open the HTML file in the browser I just get an empty screen. Can someone tell me how to do this?

vdvaxel
  • 667
  • 1
  • 14
  • 41

1 Answers1

0

you're going to need a webserver to serve the webpages on localhost using php. since you mentioned that you're a beginner peek at php it covers the fundamentals. as for the webserver, since it's a local project, you're welcome to use xampp or if you're adventurous use apache. save your .html as .php and embed the html code inside. there's a tutorial in the link. also make sure to take a peek at the documentation for php enabled pages and another nice tutorial by udemy xampp

EvOlaNdLuPiZ
  • 600
  • 1
  • 4
  • 21
  • There is no easier way to do this if you're running locally? – vdvaxel Jul 13 '18 at 18:49
  • according to the 'getting started' section of [php official documentation](http://php.net/manual/en/getting-started.php) it states you're assumed to have a server that supports php. "_we assume that your server has activated support for PHP_" – EvOlaNdLuPiZ Jul 13 '18 at 18:53
  • download xampp and configure it. create .php file and add the text `` then move the file to '\xampp\htdocs\'. now open a browser and navigate to the php file. typically it's localhost\name_of_php_file.php – EvOlaNdLuPiZ Jul 13 '18 at 18:56