Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Python CGI: how to retrieve variables passed by URL

Reply
Thread Tools

Python CGI: how to retrieve variables passed by URL

 
 
Sean Berry
Guest
Posts: n/a
 
      04-23-2004
If I go to my cgi python script with
localhost/cgi-bin/script-name.cgi?variable=value

How do I gather this value?

Thanks in advance.


 
Reply With Quote
 
 
 
 
Sean Berry
Guest
Posts: n/a
 
      04-23-2004
This may help, but not sure if there is a better, built in way.

print os.environ["QUERY_STRING"].split("=")[1]

prints value if I use localhost/cgi-bin/script-name.cgi?variable=value and
this will work... but is there a better way?



"Sean Berry" <(E-Mail Removed)> wrote in message
news:hU1ic.86730$U83.37750@fed1read03...
> If I go to my cgi python script with
> localhost/cgi-bin/script-name.cgi?variable=value
>
> How do I gather this value?
>
> Thanks in advance.
>
>



 
Reply With Quote
 
 
 
 
Heiko Wundram
Guest
Posts: n/a
 
      04-23-2004
Am Freitag 23 April 2004 07:42 schrieb Sean Berry:
> print os.environ["QUERY_STRING"].split("=")[1]
>
> prints value if I use localhost/cgi-bin/script-name.cgi?variable=value and
> this will work... but is there a better way?


Start python, and type import cgi and then help(cgi). The cgi module should
take care of what you need perfectly. If the docstrings aren't enough to get
you started, go to www.python.org -> Documentation -> Global Module Index and
check the documentation of the cgi module there.

HTH!

Heiko.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Retrieve url's of all jpegs at a web page URL grimmus Python 3 09-16-2009 05:12 AM
Retrieve ext. variables in python program alfa1234 Python 7 07-19-2006 09:32 PM
Illegal characters in variables passed via a fat url? Fernie HTML 10 12-21-2004 11:53 PM
Python C extension: Value different if passed as list than if passed as number Anand Python 2 09-11-2003 01:02 AM



Advertisments