bottle icon indicating copy to clipboard operation
bottle copied to clipboard

bottle route URL url encode path

Open AdamGracery opened this issue 2 years ago • 6 comments

http://localhost:8080/test/我 @get('/test/') def testme(name): return 'good'

don't work. but ERROR.

http://localhost:8080/test/hello URL work fine.

I know http://localhost:8080/test?a=我 also work fine. but I want to know how to make it work. In URL PATH have some unicode words. Wireshark display Its UTF-8 URL Encoded. http://localhost:8080/test/%E6%88%91

how to set bottle Make it work. Thank YOU!

AdamGracery avatar Sep 03 '22 13:09 AdamGracery

What do you mean by „http://localhost:8080/test/hello URL work fine“? Not with the @get('/test/') route. That matches /test/ but not /test/anything where it doesn't matter what anything is — even if it is just ASCII.

If you want a route for /test/我 you obviously have to use @get('/test/我').

Marrin avatar Sep 03 '22 16:09 Marrin

i have a mistake. @get('/test/') def testme(name): return 'good'

I mean unicode URL not work. How to work?

AdamGracery avatar Sep 04 '22 06:09 AdamGracery

I can't type <> in this post

AdamGracery avatar Sep 04 '22 06:09 AdamGracery

i have a mistake. @get('/test/<name>') def testme(name): return 'good'

I mean unicode URL not work. How to work?

AdamGracery avatar Sep 04 '22 07:09 AdamGracery

This work fine with both the development version and latest release of bottle and both curl http://localhost:8080/test/我 and curl http://localhost:8080/test/%E6%88%91. Please provide a full example (and use github code formatting or link to a gist or repository to avoid misunderstandings) and also tell us the actual error you get, including the error message and stack trace.

defnull avatar Sep 04 '22 07:09 defnull

I have tested and it seems to work correctly, try this @AdamGracery : bottle v0.12.23 python 3.10.4

from bottle import run, get

@get('/test/<name>')
def test(name):
    print(name)
    return name

run()

bottle log

我
127.0.0.1 - - [19/Oct/2022 21:39:26] "GET /test/%E6%88%91 HTTP/1.1" 200 3
我
127.0.0.1 - - [19/Oct/2022 21:39:28] "GET /test/æ HTTP/1.1" 200 3

bash

curl http://localhost:8080/test/%E6%88%91
我%
curl http://localhost:8080/test/我       
我%

agalera avatar Oct 19 '22 19:10 agalera