Question

I have developed a CGI Python application, it works on a local server, but how do I compile it to run it on a remote Python CGI host?

The application uses

import cgitb
import cgi
import requests
import cookielib
import bleach
import re
Was it helpful?

Solution

Assuming this structure:

(root)
 |- html
 |  |- .htaccess
 |  |- ...
 |- lib
    |- lib1
    |  |- script1.py
    |- lib2
       |- script2.py

import sys
for path in ("/lib/lib1", "/lib/lib2",...):
    if not path in sys.path:
        sys.path.append(path)

import script1        # should work with the right paths

Aaaand... many providers require certain stuff in '.htaccess' file to make python files executable.

OTHER TIPS

This is a question to ask your web hosting company. I use Dreamhost, and you can view some python cgi script examples as well as a wiki with more information. This will probably be different for your needs, though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top