Is it possible to configure an Apache webserver to use execute Python in the same way as PHP? Meaning, you could execute python code in a <?python3 ?>
tag just like you can execute PHP in <?php ?>
tags. I am not asking about WSGI or CGI.
Here's an example of what it would look like in Python3:
magic_number.py:
<?python3
import math
number = math.sqrt(42)
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Magic number</title>
</head>
<body>
<h1>The magic number is <?python3 print(number)?></h1>
</body>
</html>
The same code in PHP would look like this:
magicNumber.py:
<?php
$number = sqrt(42);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Magic number</title>
</head>
<body>
<h1>The magic number is <?php echo $number; ?></h1>
</body>
</html>
If this is possible, how could I configure it to work in Apache?
Any help is appreciated!
from Configure apache server to run Python in special tags (like PHP)
No comments:
Post a Comment