How do i make the user enter the data from php file, send it to the python file and lastly displaying the results from python in the browser?

I tried this but its not displaying the results

————-….. hardware.php……… —————-


<!DOCTYPE html>
<html>
<head>
    <title>Hardware Reliability</title>
    
</head>
<body>
    <h1>Enter the input data</h1>
    <form action="hardwareResult.php" method="post">
        <label for="x">Enter values of x (separated by commas):</label><br/>
        <input type="text" name="x"><br/>
        <label for="y">Enter values of y (separated by commas):</label><br/>
        <input type="text" name="y"><br/><br/>
        <input type="submit" value="Submit">
    </form>
</body>
</html>

———-………..hardwareResult.php…………….————


<?php
header('Content-type: text/plain; charset=utf-8');
// get user input
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  $x = explode(",", $_POST['x']);
  $y = explode(",", $_POST['y']);
} else {
  // default values
  $x = [12,16,71,99,45,27,80,58,4,50];
  $y = [56,22,37,78,83,55,70,94,12,40];
}

// prepare input data for Python script
$input_data = array(
    'x' => $x,
    'y' => $y
);

// encode input data as JSON string
$input_json = json_encode($input_data);

// call Python script with input data as parameter
$output = shell_exec("python hardware.py '$input_json'");

// parse output from Python script
$output_data = json_decode($output, true);

// check for errors in output
if ($output_data === null) {
  echo "There was an error running the Python script.";
  exit();
}

// display results
echo "<h1>Results</h1>";
echo "<p>Hardware failure rate at t=2000 is: " . $output_data['hardware_failure_rate'] . "</p>";
echo "<p>Hardware mean life is: " . $output_data['hardware_mean_life'] . "</p>";
echo "<p>Hardware reliability at t=2000 is: " . $output_data['hardware_reliability'] . "</p>";

?>

—————-…………hardware.py…………——————–

#!C:UsersVincentAppDataLocalProgramsPythonPython310python.exe


import math
import json
import sys

def hardware_failure_rate(t, beta, eta, failure_time):
    return beta/eta*((t-failure_time)/eta)**(beta-1)

def hardware_mean_life(beta, eta, failure_time):
    return failure_time+eta*(1/beta + 1)

def hardware_reliability(t, beta, eta, failure_time):
    return math.exp(-(t-failure_time)/eta*beta)

if __name__ == "__main__":
    try:
        input_json = sys.argv[1]
        input_data = json.loads(input_json)

        x = input_data['x']
        y = input_data['y']
        xy = []
        for i, val in enumerate(x):
            xy.append(x[i]*y[i])
        x_sqrt = [i**2 for i in x]
        n = len(x)
        w = (n*sum(xy) - sum(x)*sum(y))/(n*sum(x_sqrt) - sum(x)**2)
        b = (sum(y) - w*sum(x))/n

        beta = -w
        eta = math.exp(b/beta)
        failure_time = min(x)

        t = 2000
        hardware_failure_rate = hardware_failure_rate(t, beta, eta, failure_time)
        hardware_mean_life = hardware_mean_life(beta, eta, failure_time)
        hardware_reliability = hardware_reliability(t, beta, eta, failure_time)
        output_data = {'hardware_failure_rate': hardware_failure_rate, 'hardware_mean_life': hardware_mean_life, 'hardware_reliability': hardware_reliability}
        output_json = json.dumps(output_data)
        print(output_json)

    except Exception as e:
        print("Error: {}".format(str(e)))

I need to display the results in the browser but the it keeps displaying “There was an error running the Python script.”