A simple tool to execute Python code embedded within HTML files (imagine PHP).
- Execute Python code within HTML files.
- Keeps same memory across all python blocks.
- Can acccess GET & POST params
- Maintaining sessions across pages [Work in progress]
- Setting Mime type of the page [Work in progress]
- Apache httpd server
- Python3
sudo add-apt-repository ppa:deebash/direct-python
sudo apt-get update
sudo apt-get install direct-python
Example usage
Write the below content in a file and save it with extension .dp (Direct-Python)
hello.dp
<!DOCTYPE html>
<html>
<head>
<title>Python Test</title>
</head>
<body>
<?dp
print('<p>Hello World</p>')
a = "~DP_GET['name']" # using double quotes accepts string
# count = ~DP_GET['total'] to get integer
# userId = ~DP_POST['userId'] to get POST params
?>
<hr>
<p>Hello!
<?dp
print(a)
?>
</p>
</body>
</html>
Just like PHP, you need to use dp after the question mark. Save the file in your root /var/www/html and access it through localhost/hello.dp
Write your feedback to [email protected] Author: Deebash Dharmalingam (deebash.org)