Author |
|
jfha73
Joined: 18 Aug 2011 Posts: 62 Location: New York
|
Posted: Sun 31 May '20 20:34 Post subject: How to run Python files without mod_wsgi? |
|
|
Hey guys,
I noticed that mod_wsgi uses apache with prefork module and other modules like http2 are not compatible with prefork, is there any other module I can use to run python files? if so, which one and how?
Thanks. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Fri 05 Jun '20 15:51 Post subject: |
|
|
You can run python as cgi. Then every script that you call from the web needs a shebang line like
Code: | #!/usr/bin/env python
|
And you need to send the correct header like (note the empty line after the header is needed before the content follows.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-# enable debugging
import cgitb
cgitb.enable() print("Content-Type: text/html;charset=utf-8")
print()
print("Hello World!") |
|
Back to top |
|
jfha73
Joined: 18 Aug 2011 Posts: 62 Location: New York
|
Posted: Sat 06 Jun '20 2:22 Post subject: |
|
|
I tried as both, CGI and FastCGI and in both cases error.log keeps saying:
FastCGI:
End of script output before headers
CGI:
The system cannot find the file specified.
Any ideas what can be causing this? |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Sat 06 Jun '20 7:05 Post subject: |
|
|
James Blond wrote: |
Code: |
#!/usr/bin/env python
^
|
|
I'm not a Linux person but should that still not be
#!/usr/bin/env/python ? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Sat 06 Jun '20 13:28 Post subject: |
|
|
The white space is correct. It is like on windows
|
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
|
Back to top |
|