python tornado get request url
You can get current url inside RequestHandler
using self.request.uri
:
class MainHandler(tornado.web.RequestHandler): def get(self): self.write(self.request.uri)
I think what you're looking for is self.request.path
. Look at the functions available for HTTPServerRequest
.
class MainHandler(tornado.web.RequestHandler): def get(self): self.write(self.request.path)
Use self.request.full_url()
if you want to access the whole URL of the request (protocol + subdomain + domain + path + query). It will return, for example: https://myserver.com/profiles?id=115
.
Use self.request.uri
if you want to access URI (path + query). It will give, for example: /profiles?id=115
.
Use self.request.path
if you want to access just the path without query string. It will give, for example: /profiles
.