bottle
bottle copied to clipboard
bottle route URL url encode path
http://localhost:8080/test/我
@get('/test/
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!
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/我')
.
i have a mistake.
@get('/test/
I mean unicode URL not work. How to work?
I can't type <>
in this post
i have a mistake.
@get('/test/<name>')
def testme(name):
return 'good'
I mean unicode URL not work. How to work?
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.
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/我
我%