문제

I am new to Python, and I am trying to run a web.py app with Python Anywhere, but I keep getting the No template named index error. I've modified wsgi.py to use the following:

import web
import MySQLdb

urls = (
  '/', 'index'
)

render = web.template.render('/home/user/templates/')

Any help would be greatly appreciated.

도움이 되었습니까?

해결책

You've used the literal path '/home/user/templates/'. Unless your username is actually user, there is no such directory, and therefore attempting to read the index template out of that directory is going to fail.

If your username is, say, rhpt, you'd change that to '/home/rhpt/templates/'.

Even better, you might want to use os.path.expanduser('~/templates/') instead of hardcoding your username. (Then you can give your code to a friend, or a client, and they can host it without having to edit the code.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top