Reputation: 690
I am using webpy framework. I want get current request's url in webpy.
please help me, thanks.
Upvotes: 4
Views: 4264
Reputation: 4479
Just try printing web.ctx
in your controller method and you will see a bunch of environmental variables.
from pprint import pprint
pprint(web.ctx)
So your url probably should be ctx.home + ctx.path + ctx.query
or ctx.home + ctx.fullpath
.
UPD: You may also take a look at web.url
and web.changequery
, find them in api docs: http://webpy.org/docs/0.3/api
Upvotes: 5
Reputation: 108522
Is ctx path what you are after?
Data Found in ctx
Request
path – the path requested by the user, relative to the current application. If you are using subapplications, any part of the url matched by the outer application will be trimmed off. E.g. you have a main app in code.py, and a subapplication called admin.py. In code.py, you point /admin to admin.app. In admin.py, you point /stories to a class called stories. Within stories, web.ctx.path will be /stories, not /admin/stories. E.g. /articles/845
Upvotes: 1