0

On my synology I have webstation up and running (tested) Default server is Apache 2.4. By default, on DSM 7, Python is installed. Now I created a simple test.py script which I call from my browser:

#!/usr/bin/python
import os

print ("Content-type: text/html\n\n")
print ("<html>Hello world!</html>")

if 'REQUEST_METHOD' in os.environ :
  print ("This is a webpage")
else :
  print ("This is not a webpage")

When I run this "192.bla.bla/web/test.py" the code is not executed but just displayed. So I get this in my browser:

#!/usr/bin/python
import os

print ("Content-type: text/html\n\n")
print ("<html>Hello world!</html>")

if 'REQUEST_METHOD' in os.environ :
  print ("This is a webpage")
else :
  print ("This is not a webpage")

Obviously Python is not executed so I searched the internet and found this, outdated German, topic: Link to Topic

Telling me to change some config files. However the directories these files should contain are not on my system. I'm also not sure if this even is the solution as this topic is outdated.

Does anyone have Python running on Synology webstation?

hacking_mike
  • 1,005
  • 1
  • 8
  • 22

1 Answers1

0

Try using a php server and page and then using this in the index.php

<?php 

$command = escapeshellcmd('/usr/custom/test.py');
$output = shell_exec($command);
echo $output;

?>
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 01 '22 at 05:52