Can someone point me in the right direction to serving a python-based web service?
e.g., I created test.py in the public folder and tried to access it via http://domain/test.py, but get an HTTP 500. PHP files like test.php work fine. I saw there is supposed to be python/CGI support on the webserver information.
The content of the python file is just:
print("hello")
I also tried with a shebang "#!/usr/bin/python" and "chmox a+x test.py"
Hosting a python file
-
- A regular
- Posts: 42
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Fri Nov 16, 2012 2:42 pm
Re: Hosting a python file
If you use the CGI method, you'll need to print the CGI header. For instance,
Using the WSGI method, things are a bit more complicated and might require extra configuration on our end, after you've installed the software.
Code: Select all
#!/usr/bin/python
print("Content-type: text/html\n\n");
print("Hello, world!")
Re: Hosting a python file
Thanks, I should have known that - I know the php interpreter sends headers under the hood too