Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24810 > unrolled thread

Re: How can i do python form post request?

Started byThomas Jollans <t@jollybox.de>
First post2012-07-03 11:24 +0200
Last post2012-07-03 11:24 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How can i do python form post request? Thomas Jollans <t@jollybox.de> - 2012-07-03 11:24 +0200

#24810 — Re: How can i do python form post request?

FromThomas Jollans <t@jollybox.de>
Date2012-07-03 11:24 +0200
SubjectRe: How can i do python form post request?
Message-ID<mailman.1736.1341307499.4697.python-list@python.org>
On 07/03/2012 07:08 AM, gmspro wrote:
> 
> form.html:
> <form action="p.py" method="post">
>  <input type="text" id="id_text" name="name_text" />
>  <input type="submit" id="id_submit" name="name_submit" />
> </form>
> 
> p.py:
> #!/usr/bin/python
> 
> #what to write here...
> 
> Both files are put in /var/www/ , now from http://localhost/form.html,
> if i click the submit button would i execute the p.py  and how can i get
> the value of textbox?
> 
> Any answer will be highly appreciated.
> Thanks in advanced.

First, you need to tell the web server to execute your Python script.
What you do next depends on how you've done that.

The simplest way is probably to pub p.py in your cgi-bin directory. This
could be in /var/www/cgi-bin or elsewhere, like /usr/lib/cgi-bin. You
may need to enable CGI, check the relevant documentation (or with the
admin).

When you've made sure the script is executed as a CGI script, you can
use the cgi module to get all the information you need.
http://docs.python.org/library/cgi.html

A better way to write web applications in Python is with WSGI. You can
run WSGI scripts in a number of ways, including CGI and other, more
efficient ways that integrate with the web server. Maybe somebody else
knows of a good tutorial on WSGI that they'll link here, otherwise, I'm
sure Google is your friend.

Thomas

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web