iwazovsky
iwazovsky

Reputation: 1937

Python key adding to url

I need to change key in url when user retrieves the link:

http://server.eu/word.py

to , for example:

http://server.eu/word.py?word=yellow

Could it be done by cgi library?

Also, may be now by url, but somehow in other way: I just need to send random word generated in python to the client.

Upvotes: 1

Views: 202

Answers (1)

YXD
YXD

Reputation: 32521

You should look at the Requests library, which is very pleasant to use. There are examples in the documentation on how to pass parameters:

http://www.python-requests.org/en/latest/user/quickstart/#passing-parameters-in-urls

In your case this would be something like:

payload = {'word': 'yellow'}
r = requests.get("http://server.eu/word.py", params=payload)

Upvotes: 4

Related Questions