473,386 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

problem running the cgi module

Hi everyone. I'm trying to code an HTML file on my computer to make it
work with the cgi module. For some reason I can't get it running. This
is my HTML script:

------------------------------------------------------

<form method="post" action="C:\chris_on_c\hacking\formprinter.py">
<b><i><font size="50">HOWDY!</font></b></i><br><br>

<input type="text" name="name" size="50" value=""><br><br>

<input type="submit" name="send" value="submit">
</form>

------------------------------------------------------

And here is the python program it's supposed to run with,
formprinter.py:

------------------------------------------------------

import cgi, cgitb
cgitb.enable()

form = cgi.FieldStorage()
print '<font size="12">%s</font><br>' % form['name']

------------------------------------------------------

Whenever I press submit on the HTML document, it returns the code for
"formprinter.py". Can someone tell me what I'm doing wrong?

-Thanks for any help!

Jul 18 '05 #1
4 1250
I will take a guess that you might
1) make sure cgi is enabled in your webserver configuration
2) Probably must place the cgi script under $WEBSERVERDOCS/cgi-bin
unless you alter the configuration.

Also, the webserver might need to be configured to understand what
interpreter uses .py files. (not an issue on windows)

Good luck

Jul 18 '05 #2
Thanks for the help.

Jul 18 '05 #3
chris patton wrote:
Hi everyone. I'm trying to code an HTML file on my computer to make it
work with the cgi module. For some reason I can't get it running. This
is my HTML script:

------------------------------------------------------

<form method="post" action="C:\chris_on_c\hacking\formprinter.py">
<b><i><font size="50">HOWDY!</font></b></i><br><br>

<input type="text" name="name" size="50" value=""><br><br>

<input type="submit" name="send" value="submit">
</form>
You don't seem to be using a web server at all here - the form action is a file path, not a URL. So
the browser is just going to the file system to get the .py file.

You can make a simple CGI server by
- create a directory caled cgi-bin
- put formprinter.py into it
- change the form action to action="/cgi-bin/formprinter.py"
- Open a dos console to the directory containing the cgi-bin directory
- run the command python -c "import CGIHTTPServer; CGIHTTPServer.test()"

(Don't do this with Python 2.4, it is broken - use 2.3 or 2.4.1)

Kent

------------------------------------------------------

And here is the python program it's supposed to run with,
formprinter.py:

------------------------------------------------------

import cgi, cgitb
cgitb.enable()

form = cgi.FieldStorage()
print '<font size="12">%s</font><br>' % form['name']

------------------------------------------------------

Whenever I press submit on the HTML document, it returns the code for
"formprinter.py". Can someone tell me what I'm doing wrong?

-Thanks for any help!

Jul 18 '05 #4
Thanks alot. This helps tremendously

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rami A. Kishek | last post by:
Hi - this mysterious behavior with shelve is just about to kill me. I hope someone here can shed some light. First of all, I have this piece of code which uses shelve to save instances of some...
1
by: Marc | last post by:
Hello, I've fiddled with this for quite a while and thought I had the problem solved. I had a version that would successfully compile and run. But then I had to change the code to use a...
0
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
3
by: Doug | last post by:
I'm having problems w/ the VS2005 debugger with C#. It blows past any breakpoints in even the simplest "Hello World" console application. I can't do any step-by-step debugging. I've provided the...
2
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program...
12
by: jcor | last post by:
Hi, I'm using Ubuntu 7.04. I'm writing a sript that sends files via ftp for several destinations. So far I used Net::FTP and it worked fine. My problem is that I need to send files via SFTP...
8
by: geert | last post by:
Hi all, I have a mac mini running maocosx 10.5 leopard I want to deploy a django project on. My backend is MySQL, and I have it running as a 64- bit app. Of course, apache2 is also running as...
1
by: bkamrani | last post by:
Hi Python gurus, I have installed numpy and interested in testing f2py module using the first example in the documentation. First I tried: C:\test>python "C:\Program...
20
by: Nates | last post by:
I have a .bas file saved locally that I load into my Acces project to run a particular sub. I use the following code to load the module (which works fine): I use the following loop to remove...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.