Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameters to a CGI program using the URL (python)

Tags:

python

html

cgi

As the title suggests, I'm trying to pass parameters into my cgi script so that when you type in (for example): www.helloworld.com/cgi-bin/world.py?post=101, the script will display that post

I've tried the following:

link = '<a href="world.py?post=%s">test</a>' % postNumber

link = cgi.FieldStorage()
id = link.getvalue('post')
print id

but the value of id is nothing. It's like it's not reading the link properly or something.

Please help!

like image 389
DCrocovC Avatar asked Apr 07 '26 07:04

DCrocovC


1 Answers

How about:

id = link["post"].value
print id
like image 167
Alex Reynolds Avatar answered Apr 09 '26 20:04

Alex Reynolds