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 actuallyuser, there is no such directory, and therefore attempting to read theindextemplate 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.)