bottlepy / bottle

bottle.py is a fast and simple micro-framework for python web-applications.
http://bottlepy.org/
MIT License
8.33k stars 1.46k forks source link

bottle route URL url encode path #1392

Open AdamGracery opened 1 year ago

AdamGracery commented 1 year ago

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!

Marrin commented 1 year ago

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/我').

AdamGracery commented 1 year ago

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

I mean unicode URL not work. How to work?

AdamGracery commented 1 year ago

I can't type <> in this post

AdamGracery commented 1 year ago

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

I mean unicode URL not work. How to work?

defnull commented 1 year ago

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.

agalera commented 1 year ago

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/我       
我%