I need to pass strings containing slashes through the last argument in a url to my bottlepy server but since slashes get treated like argument separators the server doesn't handle it the way I need to. I found a page about how flask supports this: http://flask.pocoo.org/snippets/76/ But haven't found a similar solution in bottle yet
Sounds like you want :path:
:path matches all characters including the slash character in a non-greedy way and may be used to match more than one path segment.
For example,
@route('/root/<path:thepath>')
def callback(thepath):
# `thepath` is everything after "/root/" in the URI.
...
EDIT: In response to OP's comment (below), here's a snippet which works for me:
from bottle import Bottle, route
app = Bottle()
@app.route('/add/<uid>/<collection>/<group>/<items:path>')
def add(uid, collection, group, items):
return 'your uri path args: {}, {}, {}, {}\n'.format(uid, collection, group, items)
app.run(host='0.0.0.0', port=8081)
Yields:
% ~>curl 'http://127.0.0.1:8081/add/1/2/3/and/now/a/path'
your uri path args: 1, 2, 3, and/now/a/path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With