How to accept strings with special characters in them?

14 views
Skip to first unread message

peng...@gmail.com

unread,
Sep 23, 2018, 8:00:12 AM9/23/18
to bottlepy
I use the following bottle code.

@route('/hello/<name>')
def index(name):
    print name
    return template('<b>Hello {{name}}</b>!', name=name)

run(host='localhost', port=8080)


Neither of the following wget command will return a name with slash in it. Does anybody know how to allow it take strings with special characters like slashes? Thanks.

peb aryan

unread,
Sep 24, 2018, 5:38:39 AM9/24/18
to bott...@googlegroups.com
use :path filter

from tutorial https://bottlepy.org/docs/dev/tutorial.html :

:path matches all characters including the slash character in a non-greedy way and can be used to match more than one path segment.

usage example in static file routing

@route('/static/<path:path>')
def callback(path):
    return static_file(path, ...)
> --
> --
> You are member of the "bottlepy" group at google groups.
> See http://groups.google.de/group/bottlepy for mailing list options.
> See http://bottlepy.org/ for news and documentation.
>
> ---
> You received this message because you are subscribed to the Google Groups "bottlepy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Marcel Hellkamp

unread,
Sep 24, 2018, 6:09:02 AM9/24/18
to bott...@googlegroups.com

That said, the paths /hello/abc/x and /hello/abc%2Fx are equivalent and indistinguishable on server-side.

Reply all
Reply to author
Forward
0 new messages