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.
Forum Archive
CGIHTTPServer
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=t
The problems I see:
1) I don't think pythonista can do fork, popen, etc. That basically means you are limited to using python scripts.
2) 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 like execfile. 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 attributes have_fork, have_popen2 and have_popen3 to False since Pythonista seems to think os has all of those methods but they all raise errors.