开发者

Routes in Pylons: Mapping to explicit .htm file

开发者 https://www.devze.com 2022-12-19 00:16 出处:网络
How do I write a route to map to an explicit .htm file? E.g. I have a something.htm under /templates in Pylon开发者_如何学编程s and I want to map http://myserver.com/something.htm to something.htm un

How do I write a route to map to an explicit .htm file?

E.g. I have a something.htm under /templates in Pylon开发者_如何学编程s and I want to map http://myserver.com/something.htm to something.htm under /templates. Can I do this with Routes for Pylons or does everything get mapped to some combination of /controller/action/id ?

I would assume one way is to do: map.connect('something.htm', '/something.htm', controller='something', action='something') and create a dummy controller for it (which just returns render(/something.htm))?

This seems like cumbersome for this simple job.

Any ideas?


not sure if this is the best solution, but i have a mapping

map.connect('{name}', controller='something', action='identity')

which basically points to the name

def identity(self, name) return render('/' + name)

is there any security risk with this or what's the standard solution for this?


Actually, that's what the /public directory is for. Files in /public are matched before things in the map.connect() table. So if you put foo.html in /public directly, http://www.example.com/foo.html will send you to that page.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号