Catching the url path following a python cgi scrip

2019-07-18 05:51发布

问题:

It's better if I do an example to explain my question:

Filename of cgi script: 'awesome'
URL: http://omgpython.com/awesome
'awesome' script runs normally.

I append a 'fake' path: '/omg/so/fake'
URL: http://omgpython.com/awesome/omg/so/fake'

'awesome' script runs normally without any errors, but is it possible to catch the 'fake' path within 'awesome'?

I'm trying to clean the URL by not using URL params.

回答1:

You want os.environ['PATH_INFO']. In the second example it will contain "/omg/so/fake".



标签: python url cgi