What Anand posted will work. Your templates/ directory has to be in the same root directory as the python file; otherwise the development server would not have worked. If I'm mistaken, post your directory tree for the project so we can see what's going on
On Mon, Oct 22, 2012 at 4:15 AM, redfish <[email protected]> wrote: > but the current python file and 'templates' in different directory > > 在 2012年10月22日星期一UTC+8下午2时07分17秒,Anand写道: >> >> On Mon, Oct 22, 2012 at 11:15 AM, 吕仁坤 <[email protected]> wrote: >> > The following code works using the development server but not when >> > running >> > on my Apache server. >> > >> > render = web.template.render('templates/') >> > return render.index(self) >> > >> > What I don't want to do is use an absolute path, because I'd like to be >> > able >> > to move my project files around without having to tinker with the code >> > to >> > keep it working. >> >> Try this: >> >> import os.path >> >> root = os.path.dirname(__file__) >> render = web.template.render(os.path.join(root, "templates/")) >> >> Anand > > -- > You received this message because you are subscribed to the Google Groups > "web.py" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/webpy/-/aOLVcNW4QzAJ. > > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/webpy?hl=en. -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
