omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    2
    4
    3375
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Omega0
      Omega0 last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          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

          1 Reply Last reply Reply Quote 0
          • Omega0
            Omega0 last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors