if __name__ == '__main__': app.run(debug=True, port=3000)
返回结果:
1 2 3 4 5 6 7 8 9
qq@zz:~$ curl http://127.0.0.1:3000/users/kaka/ { "a": 1 } qq@zz:~$ curl http://127.0.0.1:3000/users/kaka <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>Redirecting...</title> <h1>Redirecting...</h1> <p>You should be redirected automatically to target URL: <a href="http://127.0.0.1:3000/users/kaka/">http://127.0.0.1:3000/users/kaka/</a>. If not click the link.
找解决
在werkzeug/routing.py中:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
- you receive a `RequestRedirect` exception with a `new_url` attribute. This exception is used to notify you about a request Werkzeug requests from your WSGI application. This is for example the caseif you request ``/foo`` although the correct URL is ``/foo/`` You can use the `RequestRedirect` instance as response-like object similar to all other subclasses of `HTTPException`.
`string` Rule strings basically are just normal URL paths with placeholders in the format ``<converter(arguments):name>`` where the converter and the arguments are optional. If no converter is defined the `default` converter is used which means `string` in the normal configuration.
URL rules that end with a slash are branch URLs, others are leaves. If you have `strict_slashes` enabled (which is the default), all branch URLs that are matched without a trailing slash will trigger a redirect to the same URL with the missing slash appended.