Python Web Tutorial #1
Click the button below to run a simple Python script.
Script 1. python-web-tutorial-2.py
Create a basic Python script that prints Hello World. Name the script python-web-tutorial-1.py.
print("Coder Fairy: Hello World!")
Script 2. python-web-tutorial-1.php
Create a php script that runs the Python script, stores the output of Python’s print statement, and then prints the results to the webpage. Name this script python-web-tutorial-1.php. python-web-tutorial-1.py in the script below should match the name of your Python script from the previous step.
Upload the Python and PHP scripts to your WordPress server:
1. Log into cPanel
2. Click on File Manager
3. Navigate to the folder that you would like to save these scripts to
4. Click Upload and then upload the two scripts python-web-tutorial-2.py and python-web-tutorial-2.php
Script 3. python-web-tutorial-2.html
Create a html and Javascript script. The html portion creates a button with the id of “myButton“. The Javascript portion that calls the php script from step 2 to gets the print statement from the Python script and then prints the output.
In the code below, replace https://coderfairy.com/code/python-web/2/python-web-tutorial-2.php with the location that you saved your php script in the previous step.
My Page