【发布时间】:2019-04-30 01:12:37
【问题描述】:
我有这段代码可以将 CSS 文件与 HTML 连接起来:
from bottle import static_file
@route("/static/<filename>")
def static(filename):
return static_file(filename, root="static")
然后我有这个代码:
@route("/edit/<name>")
def edit(name):
return template("edit")
问题是我的模板 edit.html 无法连接到静态文件夹中的 CSS 文件。但是当我有这样的代码时它可以工作:
@route("/edit/")
def edit(name):
return template("edit")
...没有名称标签
【问题讨论】:
-
我很困惑。
edit的第二个版本根本不应该工作;它应该会失败,因为 Bottle 会尝试使用零参数调用您的edit函数,而它需要一个参数 (TypeError)。
标签: python-3.x bottle