Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you accept any URL in a Python Bottle server?

Tags:

python

bottle

Using a Bottle Sehttp://bottlepy.org/docs/dev/routing.html#wildcard-filters

I'd like to accept any url, and then do something with the url.

e.g.

@bottle.route("/<url:path>")
def index(url):
  return "Your url is " + url

This is tricky because URLs have slashes in them, and Bottle splits by slashes.

like image 302
Dave Avatar asked Nov 17 '11 17:11

Dave


1 Answers

Based on new Bottle (v0.10), use a re filter:

@bottle.route("/<url:re:.+>")

You can do that with old parameters too:

@bottle.route("/:url#.+#")
like image 71
iurisilvio Avatar answered Oct 03 '22 04:10

iurisilvio