You have the following code at the top and the bottom of index.py:
cgitb.enable() print 'Content-type: text/html\n\n' print "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/msa.css\" >" # [...] ## Calling all the functions of the class template with object (objx) objx=HtmlTemplate() # [...] objx.CloseHtml() This will be called each time you import index.
To prevent this happening, put it in a block thus:
if __name__ == '__main__': cgitb.enable() print 'Content-type: text/html\n\n' print "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/msa.css\" >" # [...] ## Calling all the functions of the class template with object (objx) objx=HtmlTemplate() # [...] objx.CloseHtml() ...or better still in a functionbetter still put this code functions that can be called from elsewhere.