Get current URL in Python

前端 未结 7 2080
独厮守ぢ
独厮守ぢ 2020-12-05 18:49

How would i get the current URL with Python,

I need to grab the current URL so i can check it for query strings e.g

requested_url = \"URL_HERE\"

ur         


        
7条回答
  •  不思量自难忘°
    2020-12-05 18:52

    I couldn't get the other answers to work, but here is what worked for me:

        url = os.environ['HTTP_HOST']
        uri = os.environ['REQUEST_URI']
        return url + uri
    

提交回复
热议问题