我正在使用 pylons,并且想使用聪明的 css。
我创建了一个 Controller SassController 来处理 .sass 请求,但是在 config/routing.py 中,我不知道如何编写映射。
我想要的是:
- 客户请求:http://localhost:5000/stylesheets/questions/index.sass
- 所有此类请求都将由
SassController#index处理
我试过:
map.connect('/{path:.*}.sass', controller='sass', action='index')
但只发现:http://localhost:5000/xxx.sass会被处理,但是http://localhost:5000/xxx/yyy.sass不会的。
我现在该怎么办?
请您参考如下方法:
路由代码使用正则表达式,因此您可以让它吃掉 url 中的所有内容,而不管斜杠。
文档是 here
它看起来像:
map.connect(R'/{path:.*?}.sass', controller='SassController', action='index')
#in the SassController
def index(self, path):
return path
http://localhost:5000/blah/blah/something.sass会调用SassController.index与 path = blah/blah/something
