Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
CGIHTTPServer
-
I've been developing some CGI based scripts in Pythonista and had intended to use the CGIHTTPServer module to test them, but when I tried to import the module I got an error saying the module did not exist. I assume this is due to Apple's restrictions on executing code within apps but I wanted to check to see if it could possibly be added in a later version before I go out and try to set up a web server to test my scripts.
-
You could always install the module yourself.
This is pure python, for example found here:
https://fossies.org/linux/misc/Python-2.7.9.tgz/Python-2.7.9/Lib/CGIHTTPServer.py?m=tThe problems I see:
- I don't think pythonista can do fork, popen, etc. That basically means you are limited to using python scripts.
- The fallback mentioned when fork, etc are not available is to execute within the script... but this is a lie. It calls subprocess, which we also don't have. So you probably need to modify the logic for
if self.is_python(scriptfile):
, to use something likeexecfile
. I think you'd have to modify the stdin/stdout to get access to them.
If you are trying to use something like shell script, you may be out of luck, although stash supports a very primitave style of shell script. Again, you'd have to modify the script launching bit to have stash launch the script.
-
Actually, an older version of CGIHTTPServer might work better, since it actually does use execfile as mentioned in the comments.
https://github.com/certik/python2.6/blob/master/Lib/CGIHTTPServer.py -
The 2.6 version works for my purposes by changing the
CGIHTTPRequestHandler
class attributeshave_fork
,have_popen2
andhave_popen3
toFalse
since Pythonista seems to thinkos
has all of those methods but they all raise errors.