Clement
Clement

Reputation: 377

WebPy: AttributeError No template named index

Recently I have been trying to learn WebPy and when attempting to use a template in the tutorial (http://webpy.org/docs/0.3/tutorial) I come across this error when trying to access the page.

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 239, in process
return self.handle()

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 420, in _delegate
return handle_class(cls)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 396, in handle_class
return tocall(*args)

File "/Users/clement/Desktop/#Minecraft/index2.py", line 14, in GET
return render.index(name)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/template.py", line 1017, in __getattr__
t = self._template(name)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/template.py", line 1014, in _template
return self._load_template(name)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/template.py", line 1001, in _load_template
raise AttributeError, "No template named " + name

AttributeError: No template named index

I've looked at this Question on SOF but I couldn't get it to work in my situation. I've spent about 4 hours trying to figure this out and have attempted to rework the way I launch the service which is usually done by:

Macintosh-2:~ clement$ python /Users/clement/Desktop/\#Minecraft/index.py

Thanks!

Upvotes: 2

Views: 2491

Answers (1)

Clement
Clement

Reputation: 377

I believe I have found the answer.

To Solve:

  1. CD into the directory containing main.py (or in my case index.py)
  2. Make sure your HTML files are in a directory in the directory you cd'd into called 'templates'
  3. run via: python [full path to main.py]

Hopes this helps people with similar issues :)

(Note: Running OS X 10.8.1)

Upvotes: 1

Related Questions