Results 1 to 1 of 1
How do I get the files in this directory to execute? Everytime I navigate to the file, it shows.
Code:
Python 3.1.2 (release31-maint, Sep 17 2010, 20:34:23)
[GCC 4.4.5]
So ...
- 04-22-2011 #1Just Joined!
- Join Date
- Apr 2011
- Posts
- 2
cgi-bin
How do I get the files in this directory to execute? Everytime I navigate to the file, it shows.
So it doesn't seem to be broken. Here is the full code.Code:Python 3.1.2 (release31-maint, Sep 17 2010, 20:34:23) [GCC 4.4.5]
Any help would be appreciated.Code:#!/usr/bin/python3 def getargs( qstring ): rvalue = {} ipos = 0 prevpos = 0 while ipos < len(qstring): if qstring[ipos] == '=': kval = qstring[prevpos:ipos] ipos = ipos+1 prevpos = ipos while ipos < len(qstring): if qstring[ipos] == '&': vval = qstring[prevpos:ipos] ipos = ipos+1 prevpos = ipos break ipos = ipos+1 if ipos == len(qstring): vval = qstring[prevpos:ipos] break rvalue[kval] = vval else: ipos = ipos+1 if ipos == len(qstring): rvalue["(nokey)"] = qstring[prevpos:ipos] return rvalue print ("Content-type: text/html") print () print ("<html>") print ("<head>") print ("<title>pystat.py</title>") print ("</head>") print ("<body>") print ("<pre>") import os, sys from cgi import escape print ("<strong>Python %s</strong>" % sys.version) keys = os.environ.keys() keys.sort() for k in keys: print ("%s\t%s" % (escape(k), escape(os.environ[k]))) print ("</pre>") print ("<p>") print ("<h3>",getargs(os.environ["QUERY_STRING"]),"'s Story</h3>") myargs=getargs(os.environ["QUERY_STRING"]) char1=myargs["arg1"] char2=myargs["arg2"] print ("<p>") print (char1, "and ", char2, "went up the hill to fetch a pail of water.") print ("</body>") print ("</html>")


Reply With Quote