使用 app.mount 时,尝试在 URL 路径中使用特殊字符会失败:
http://127.0.0.1:8080/test/äöü
结果是:
Error: 400 Bad Request
Invalid path string. Expected UTF-8
test.py:
#!/usr/bin/python
import bottle
import testapp
bottle.debug(True)
app = bottle.Bottle()
app.mount('/test',testapp.app)
app.run(reloader=True, host='0.0.0.0', port=8080)
run(host="localhost",port=8080)
测试应用程序.py:
import bottle
app = bottle.Bottle()
@app.route("/:category", method=["GET","POST"])
def admin(category):
try:
return category
except Exception(e):
print ("e:"+str(e))
当不使用 app.mount 时,相同的代码可以很好地工作:
测试工作.py:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import bottle
import testapp
bottle.debug(True)
app = bottle.Bottle()
@app.route("/test/:category", method=["GET","POST"])
def admin(category):
try:
return category
except Exception(e):
print ("e:"+str(e))
app.run(reloader=True, host='0.0.0.0', port=8080)
run(host="localhost",port=8080)
这看起来像是一个错误,还是我在这里遗漏了一些东西? :/