- Messages
- 10
- Reaction score
- 0
- Points
- 0
I have a simple HTML index page, including:
<form ACTION="http://valkyrie.x10.mx/cgi-bin/post.cgi" METHOD="GET">
<textarea name="Message" rows="5" cols="40" onfocus="this.value=''; this.onfocus=null;">Enter your status update here.</textarea>
<P>
<INPUT TYPE="submit" title="FOO">
</form>
The form displays OK. When I click the button, however, I get this message:
404 Not Found
The server can not find the requested page:
valkyrie.x10.mx/cgi-bin/post.cgi?Message=hello (port 80)
The file post.cgi is in fact in the cgi-bin directory. Its permissions are set to 0777 (yes, I know that needs to be dialed back but I was being sure).
The cgi-bin folder perms are 0755. The file is shows below. It is a python file, and its first line is
#!/usr/bin/python
Anyway the message says the file is not found. Please advise me. Thanks!
The file is this:
#!/usr/bin/python
import cgi, urllib2, urllib
import cgitb
cgitb.enable()
# This file needs to be readable and writable from this cgi
file_name = "my_url"
form = cgi.FieldStorage()
# If we have Message then this is a status update.
if "Message" in form:
# Redirect back to the form
print "Status: 302 Moved"
print "Location: http://www.myurl.com/path/to/form"
print
# Read in the url from the file
f = open(file_name,'r')
base_url = f.read()
# Build the complete url with query args.
message = form["Message"].value
args = "?Message=%s" % urllib.quote(message)
# Make the request, giving the status to the script.
response = urllib2.urlopen(base_url + args)
# If we have URL then this is an URL update
if "URL" in form:
# Write the url to the file, overwriting the existing file.
f = open(file_name,'w')
f.write(form["URL"].value)
# Let the caller know it worked.
print "Content-Type: text/html"
print
print "OK"
<form ACTION="http://valkyrie.x10.mx/cgi-bin/post.cgi" METHOD="GET">
<textarea name="Message" rows="5" cols="40" onfocus="this.value=''; this.onfocus=null;">Enter your status update here.</textarea>
<P>
<INPUT TYPE="submit" title="FOO">
</form>
The form displays OK. When I click the button, however, I get this message:
404 Not Found
The server can not find the requested page:
valkyrie.x10.mx/cgi-bin/post.cgi?Message=hello (port 80)
The file post.cgi is in fact in the cgi-bin directory. Its permissions are set to 0777 (yes, I know that needs to be dialed back but I was being sure).
The cgi-bin folder perms are 0755. The file is shows below. It is a python file, and its first line is
#!/usr/bin/python
Anyway the message says the file is not found. Please advise me. Thanks!
The file is this:
#!/usr/bin/python
import cgi, urllib2, urllib
import cgitb
cgitb.enable()
# This file needs to be readable and writable from this cgi
file_name = "my_url"
form = cgi.FieldStorage()
# If we have Message then this is a status update.
if "Message" in form:
# Redirect back to the form
print "Status: 302 Moved"
print "Location: http://www.myurl.com/path/to/form"
# Read in the url from the file
f = open(file_name,'r')
base_url = f.read()
# Build the complete url with query args.
message = form["Message"].value
args = "?Message=%s" % urllib.quote(message)
# Make the request, giving the status to the script.
response = urllib2.urlopen(base_url + args)
# If we have URL then this is an URL update
if "URL" in form:
# Write the url to the file, overwriting the existing file.
f = open(file_name,'w')
f.write(form["URL"].value)
# Let the caller know it worked.
print "Content-Type: text/html"
print "OK"