Processing HTML form

B

Bradley Hintze

Hi,

I am a newbie to anything web related, I know a bit of HTML though.
I've been programing in python for a year or so so I know the language
at an intermediate level. I am wondering if its possible to get info
from an HTML form and pass it to my python code and return a page
based on the code executed. All of my web searches have been
fruitless as I quickly get lost in the jargon and perhaps not sure
what phrase i should search. Any help would be appreciated.

Thank you,
Bradley
 
G

Grant Edwards

I am a newbie to anything web related, I know a bit of HTML though.
I've been programing in python for a year or so so I know the language
at an intermediate level. I am wondering if its possible to get info
from an HTML form and pass it to my python code and return a page
based on the code executed. All of my web searches have been
fruitless as I quickly get lost in the jargon and perhaps not sure
what phrase i should search. Any help would be appreciated.

It's not clear what you want. Are you talking about Python code in an
HTTP client or an HTTP server?
 
B

Bradley Hintze

I apologize in advance for my lack of knowledge, I really do not know.
I would guess server but I quite honestly I am not clear what an 'HTTP
client' or 'HTTP server' refers to. I am running a webpage and am
serving it locally for the moment. I have a program that is already
written in Python. I want to make the program available on the web
where I receive user input from HTML forms. The user input will then
be used as parameters for the program. I hope this clear things up.

Thanks,
Bradley

It's not clear what you want.  Are you talking about Python code in an
HTTP client or an HTTP server?



--
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799
 
M

Marco Nawijn

Hi,

I am a newbie to anything web related, I know a bit  of HTML though.
I've been programing in python for a year or so so I know the language
at an intermediate level. I am wondering if its possible to get info
from an HTML form and pass it to my python code and return a page
based on  the code executed. All of my web searches have been
fruitless as I quickly get lost in the jargon and perhaps not sure
what phrase i should search. Any help would be appreciated.

Thank you,
Bradley

Hi Bradley,

If I understand correctly, you want to do the following:
1. Fill in a HTML form in a client (web browser)
2. Send the form to a webserver
3. Have the webserver extract the information from the form
4. Send the information to a python program for processing
5. Generate a new HTML page in python based on the information in
step 4
6. Send the newly generated page back to the client

Possible solutions depend a little on the constraints and/or options
you have for the webserver. If you are free in your choices I would
suggest to start with cherrypy (www.cherrypy.org) for a webserver. It
is simple to start with, very powerfull and well documented. This
would cover steps 3 and 4. For step 5 I suggest you either use the
python builtin string template facility string.Template (for simple
things). If you want more power have a look at Genshi http://genshi.edgewall.org.

The two options I mention above help you to understand whats going on.
If you feel comfortable with this, you can take a look at python web
frameworks like Django or Turbogears (or many others).

Good luck and keep us posted with what your progress.

Regards,

Marco
 
G

Grant Edwards

I apologize in advance for my lack of knowledge, I really do not know.
I would guess server but I quite honestly I am not clear what an 'HTTP
client' or 'HTTP server' refers to. I am running a webpage and am
serving it locally for the moment. I have a program that is already
written in Python. I want to make the program available on the web
where I receive user input from HTML forms. The user input will then
be used as parameters for the program. I hope this clear things up.

Something that serves a web page is an HTTP server, so it sounds like
your program is going to be run by/in the HTTP server. There are
many, many different ways to do that. For starters you need to tell
us what OS you're using and what HTTP server you're using.

Or do you want your program to _be_ an HTTP server?
 
B

Benjamin Kaplan

I apologize in advance for my lack of knowledge, I really do not know.
I would guess server but I quite honestly I am not clear what an 'HTTP
client' or 'HTTP server' refers to. I am running a webpage and am
serving it locally for the moment. I have a program that is already
written in Python. I want to make the program available on the web
where I receive user input from HTML forms. The user input will then
be used as parameters for the program. I hope this clear things up.

Thanks,
Bradley

HTTP Client = web browser.
HTTP Server = the server,

You'll probably want to use a framework like Django to help you with
this- this is exactly what they were designed to do. What the
frameworks do is let you map URLs to functions. Your form data will
get sent to the server in a POST request, and the framework will hand
that to your function as arguments. Then, your function will generate
the web page (often using a template where you just fill in the
blanks) and send that back to the browser.
 
B

Bradley Hintze

I am on Mac OSX 10.6, server is apache. If I do get this working we
will move it to the main server which also serves apache, i believe.I
dont think I want a whole new server, I'd like to serve from the
apache framework if possible.

Something that serves a web page is an HTTP server, so it sounds like
your program is going to be run by/in the HTTP server.  There are
many, many different ways to do that.  For starters you need to tell
us what OS you're using and what HTTP server you're using.

Or do you want your program to _be_ an HTTP server?



--
Bradley J. Hintze
Graduate Student
Duke University
School of Medicine
801-712-8799
 
G

Grant Edwards

I am on Mac OSX 10.6, server is apache. If I do get this working we
will move it to the main server which also serves apache, i believe.I
dont think I want a whole new server, I'd like to serve from the
apache framework if possible.

There are a couple different ways to integrate python code into
apache. You can use the normal CGI API where apache runs external
programs written in Python:

http://docs.python.org/library/cgi.html

http://gnosis.cx/publish/programming/feature_5min_python.html
http://www.cs.virginia.edu/~lab2q/lesson_1/
http://www.upriss.org.uk/python/PythonCourse.html

Or you can embed Python into apache so that it's faster and you can do
some more sophisticated stuff that's above my head:

http://www.modpython.org/
http://onlamp.com/pub/a/apache/2003/04/10/apacheandpython.html

More on both of the above at

http://www.google.com/search?q=apache+python

There are people on the list far more experienced with Python+Apache
than I, so I'll leave it at that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top