Routes in Pylons: Mapping to explicit .htm file
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.
精彩评论