![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
GET/POST vars in Python
I just started learning Python, and I'm trying to figure out how to access GET/POST form variables. Anyone know? Thanks.
|
|
|
|
|
|
#2 |
|
Banned
![]() ![]() |
With... raw sockets? CherryPy? CGI?
... ![]() |
|
|
|
|
|
#3 |
|
Expert Programmer
|
That sounds sorta complicated. Isn't there an easy way to do it? In PHP you can use $_GET['var'] or $_POST['var']...
EDIT: I believe this article covers what I was looking for. Last edited by titaniumdecoy; May 26th, 2006 at 12:36 AM. |
|
|
|
|
|
#4 | |
|
Banned
![]() ![]() |
No... I was asking you what the medium was for attaining the arguments? Are you trying to do it
Quote:
|
|
|
|
|
|
|
#5 |
|
Expert Programmer
|
I'm talking about getting information submitted to a script by an HTML form. If there's an easier/better way to do it than by using the CGI module, I'd be glad to hear about it.
|
|
|
|
|
|
#6 |
|
Banned
![]() ![]() |
I know that's what you're talking about, but it would have helped if you said what you're listening to the HTTP packets with. CherryPy, for example, makes this very easy for you. The POST/GET arguments come in directly as arguments to the functions you map to pages. http://cherrypy.org can teach you all about CherryPy.
Raw Sockets you would have to parse yourself. Not sure about CGI. Not aware of any other methods, other then the HTTP module that interfaces to the socket library. |
|
|
|
|
|
#7 |
|
Newbie
|
CGI module is the way to go. Its not too hard, very similiar to PHP besides the import statement.
|
|
|
|
|
|
#8 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
CGI is the only alternative I have on my commercial host. I find it straightforward. Here's some snips:
print "Content-type: text/html\n\n"
import os
import cgitb; cgitb.enable() #Debug aid to be removed later
import cgi
import re
import types
...
...
SERVER = os.environ
script = SERVER ['SCRIPT_NAME']
query = SERVER ['QUERY_STRING']
browser = SERVER ['HTTP_USER_AGENT']
ip = SERVER ['REMOTE_ADDR']
...
...
form = cgi.FieldStorage ()
page = form.getfirst ("page", "0-0")
...
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 | |
|
Expert Programmer
|
Thanks DaWei.
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|