•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 374,165 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,249 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 899 | Replies: 1
![]() |
•
•
Join Date: Nov 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
For some reason I cannot get my CGI Script to work with my Dreamweaver file. I feel like it may have something to do with where I'm saying things are located. For example, the company website that I am working on has its files located on another website. I assume there needs to be a cgi-bin folder where all the web files are located. I placed a cgi-bin folder there with python.exe, cgi.py, string,py and my python file, request.py.
This is part of the code for my form in Dreamweaver. I have highlighted the form action that I placed in the code so that it would be able to read the python file (or supposedly be able to read the file):
<table width="561" height="332" border="0" align="left">
<tr>
<td width="555" height="328" valign="top"><div align="center"><form action="cgi-bin/request.py" enctype="multipart/form-data">
<table width="453" border="0">
<tr>
<td width="447"><div align="left"><span
class="style37">Name: </span>
<input maxlength="40" name="name" />
<br />
<br />
<span
class="style37">Email: </span>
<input id="email" maxlength="100" size="40"
name="email" />
<br />
<br />
<span class="style37">Company:</span>
<input
id="company" maxlength="100" size="40" name="company" />
<br />
<br />
Part of my (simple) python file is as follows:
#!/usr/bin/python
print "Content-type: text/html\n\n"
import cgi
import string
def main():
form = cgi.FieldStorage()
print "<head><title>Request Information Sent</title></head>"
print "<body><h1 align = center>"
print "<p>Thank you for your interest in aapptec products. The information has been sent.</body>"
name = form.getvalue("name")
if name == "":
print "No name provided, please go back and provide a name."
else:
print "Hello," + str(name) + "."
print "<font size = '4' face = 'Arial'>"
print "<br>"
print "<br>"
email = form.getvalue("email")
if email != "":
print "Email: " + str(email) + "<br>"
else:
print "No email provided.<br>"
However, when I type something in the fields on the form and click submit, one of two things either pops up. First, it says that the page cannot be found (which obviously has something to do where things are located). Second, it says that I have used an invalid HTTP verb. The URL comes up to be: http://aapptec.com/cgi-bin/request.p...end+to+aapptec
Any help would be GREATLY appreciated!!!!! If there is anything else that you need to know to help me, then please let me know!! Thanks so much.
This is part of the code for my form in Dreamweaver. I have highlighted the form action that I placed in the code so that it would be able to read the python file (or supposedly be able to read the file):
<table width="561" height="332" border="0" align="left">
<tr>
<td width="555" height="328" valign="top"><div align="center"><form action="cgi-bin/request.py" enctype="multipart/form-data">
<table width="453" border="0">
<tr>
<td width="447"><div align="left"><span
class="style37">Name: </span>
<input maxlength="40" name="name" />
<br />
<br />
<span
class="style37">Email: </span>
<input id="email" maxlength="100" size="40"
name="email" />
<br />
<br />
<span class="style37">Company:</span>
<input
id="company" maxlength="100" size="40" name="company" />
<br />
<br />
Part of my (simple) python file is as follows:
#!/usr/bin/python
print "Content-type: text/html\n\n"
import cgi
import string
def main():
form = cgi.FieldStorage()
print "<head><title>Request Information Sent</title></head>"
print "<body><h1 align = center>"
print "<p>Thank you for your interest in aapptec products. The information has been sent.</body>"
name = form.getvalue("name")
if name == "":
print "No name provided, please go back and provide a name."
else:
print "Hello," + str(name) + "."
print "<font size = '4' face = 'Arial'>"
print "<br>"
print "<br>"
email = form.getvalue("email")
if email != "":
print "Email: " + str(email) + "<br>"
else:
print "No email provided.<br>"
However, when I type something in the fields on the form and click submit, one of two things either pops up. First, it says that the page cannot be found (which obviously has something to do where things are located). Second, it says that I have used an invalid HTTP verb. The URL comes up to be: http://aapptec.com/cgi-bin/request.p...end+to+aapptec
Any help would be GREATLY appreciated!!!!! If there is anything else that you need to know to help me, then please let me know!! Thanks so much.
•
•
Join Date: Dec 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
ok, first off, the server needs to be able to run python...
make sure it has python installed, set the mime type, and make sure python can be found on the system path (if you cannot do this and the site host doesnt have it configured, stop here... you will need to use another language thats supported by the server such as php or perl)
also, you need to make the permissions of the files such that the server has the ability to execute and read the files (chmod 755 on a linux system).
usually a hosting company will have the ability to do all this for you (though you may need to ask their moderators or admins if they have python available for you to use, and for a module list if they do so you know what modules you can use). my experience is that most commercial hosts DO have python even if it is not advertised and you almost always have to configure the mime type yourself (even if they do advertise python availability). If this is not a comercial hos, and is instead your client companies own server, then you will need to talk to their network admin if you want python installed for you, otherwise your shit out of luck.
lastly, wherever you have an executable script such as cgi or py files, you need explicit permission to execute those scripts within the directory they are contained in.
Obviosly, your gonna need to contact some people to find out some answers now, i just hope this helped.
as a side note, if you cant get access to python, there is always client side java scripting which should work regardless of the server, but may not have all the functionality you wanted your python scripts to be capable of.
make sure it has python installed, set the mime type, and make sure python can be found on the system path (if you cannot do this and the site host doesnt have it configured, stop here... you will need to use another language thats supported by the server such as php or perl)
also, you need to make the permissions of the files such that the server has the ability to execute and read the files (chmod 755 on a linux system).
usually a hosting company will have the ability to do all this for you (though you may need to ask their moderators or admins if they have python available for you to use, and for a module list if they do so you know what modules you can use). my experience is that most commercial hosts DO have python even if it is not advertised and you almost always have to configure the mime type yourself (even if they do advertise python availability). If this is not a comercial hos, and is instead your client companies own server, then you will need to talk to their network admin if you want python installed for you, otherwise your shit out of luck.
lastly, wherever you have an executable script such as cgi or py files, you need explicit permission to execute those scripts within the directory they are contained in.
Obviosly, your gonna need to contact some people to find out some answers now, i just hope this helped.
as a side note, if you cant get access to python, there is always client side java scripting which should work regardless of the server, but may not have all the functionality you wanted your python scripts to be capable of.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
Other Threads in the Python Forum
- Previous Thread: XML parsing the weather
- Next Thread: Making it look "prettier" in wxpython?!


Linear Mode