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


Groups > comp.lang.python > #24810

Re: How can i do python form post request?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <t@jollybox.de>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'executed': 0.07; 'skip:/ 10': 0.07; 'subject:form': 0.07; 'scripts': 0.09; 'subject:How': 0.09; 'python': 0.09; 'other,': 0.09; 'script,': 0.09; 'url:localhost': 0.09; 'subject:python': 0.11; 'elsewhere,': 0.16; 'received:192.168.1.50': 0.16; 'simplest': 0.16; 'wsgi': 0.16; 'wsgi.': 0.16; 'wrote:': 0.17; 'directory.': 0.17; 'script.': 0.17; 'subject:request': 0.17; '(or': 0.18; 'module': 0.19; 'otherwise,': 0.20; 'friend.': 0.22; 'somebody': 0.23; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'appreciated.': 0.26; 'am,': 0.27; 'first,': 0.27; 'skip:# 10': 0.27; 'integrate': 0.27; 'run': 0.28; 'cgi': 0.29; "they'll": 0.29; 'probably': 0.29; "i'm": 0.29; 'maybe': 0.29; 'knows': 0.30; 'that.': 0.30; 'button': 0.30; 'server.': 0.32; 'url:python': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; 'tutorial': 0.33; 'done': 0.34; 'thanks': 0.34; 'server': 0.35; 'subject:?': 0.35; 'next': 0.35; 'url:org': 0.36; 'depends': 0.36; 'url:library': 0.36; 'execute': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'url:docs': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'google': 0.39; 'received:192.168': 0.40; 'enable': 0.60; 'your': 0.60; 'link': 0.60; "you've": 0.61; 'received:62': 0.62; 'thomas': 0.62; 'information': 0.63; 'more': 0.63; 'url:cgi': 0.65; 'click': 0.76; 'from:addr:t': 0.84; 'here...': 0.84; 'received:62.75': 0.84; 'url:form': 0.91
Date Tue, 03 Jul 2012 11:24:57 +0200
From Thomas Jollans <t@jollybox.de>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: How can i do python form post request?
References <1341292136.76763.YahooMailClassic@web164601.mail.gq1.yahoo.com>
In-Reply-To <1341292136.76763.YahooMailClassic@web164601.mail.gq1.yahoo.com>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1736.1341307499.4697.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1341307499 news.xs4all.nl 6976 [2001:888:2000:d::a6]:48743
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:24810

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web