Python:使用 bottle 框架从浏览器中检索当前 URL

Python: Retrieve the current URL from the browser using bottle framework

我希望使用 bottle 框架检索完整的 url 浏览器。查看了文档,发现最好的方法是使用 geturl() 方法。我该怎么办?

bottle.request.urlreturnsurl。 (它在幕后调用 geturl。)

from bottle import Bottle, request

app = Bottle()

@app.route('/')
def root():
    return ['this url is: {}'.format(request.url)]

app.run(host='0.0.0.0', port=8080)

进行中:

% python test.py &
Bottle v0.12.8 server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:8080/
Hit Ctrl-C to quit.

% curl 'http://localhost:8080/?hello'
this url is: http://localhost:8080/?hello