我正在使用web.py构建一个简单的HTML模板,但每次我尝试运行基本应用程序时系统都会抛出错误。我不确定如何诊断。完整的回溯如下。那里的任何人都有关于诊断方法的想法吗?
有人在此链接上提出了类似的问题,但未得到回答:Inheritance in web.py?
来源我模仿我的文件:http://learnpythonthehardway.org/book/ex50.html
<html>
<head>
<title>Gothons Of Planet Percal #25</title>
</head>
<body>
$if greeting:
I just wanted to say <em style="color: green; font-size: 2em;">$greeting</em>.
$else:
<em>Hello</em>, world!
</body>
import web
urls = (
'/', 'Index'
)
app = web.application(urls, globals())
render = web.template.render('templates/')
class Index(object):
def GET(self):
greeting = "Hello World"
return render.index(greeting = greeting)
if __name__ == "__main__":
app.run()
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/web/wsgiserver/__init__.py", line 1245, in communicate
req.respond()
File "/Library/Python/2.7/site-packages/web/wsgiserver/__init__.py", line 775, in respond
self.server.gateway(self).respond()
File "/Library/Python/2.7/site-packages/web/wsgiserver/__init__.py", line 2018, in respond
response = self.req.server.wsgi_app(self.env, self.start_response)
File "/Library/Python/2.7/site-packages/web/httpserver.py", line 268, in __call__
return self.app(environ, xstart_response)
File "/Library/Python/2.7/site-packages/web/httpserver.py", line 236, in __call__
return self.app(environ, start_response)
File "/Library/Python/2.7/site-packages/web/application.py", line 276, in wsgi
result = self.handle_with_processors()
File "/Library/Python/2.7/site-packages/web/application.py", line 246, in handle_with_processors
return process(self.processors)
File "/Library/Python/2.7/site-packages/web/application.py", line 243, in process
raise self.internalerror()
File "/Library/Python/2.7/site-packages/web/application.py", line 467, in internalerror
return debugerror.debugerror()
File "/Library/Python/2.7/site-packages/web/debugerror.py", line 305, in debugerror
return web._InternalError(djangoerror())
File "/Library/Python/2.7/site-packages/web/debugerror.py", line 290, in djangoerror
djangoerror_r = Template(djangoerror_t, filename=__file__, filter=websafe)
File "/Library/Python/2.7/site-packages/web/template.py", line 844, in __init__
code = self.compile_template(text, filename)
File "/Library/Python/2.7/site-packages/web/template.py", line 922, in compile_template
ast = compiler.parse(code)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 51, in parse
return Transformer().parsesuite(buf)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 128, in parsesuite
return self.transform(parser.suite(text))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 124, in transform
return self.compile_node(tree)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 167, in compile_node
raise WalkerError, ('unexpected node type', n)
WalkerError: ('unexpected node type', 339)
答案 0 :(得分:1)
首先,您应该在HTML页面中添加Collections.sort(userPointList, (item1, item2) -> {
int firstUser = item1.getPoint() ? 0 : 1;
int secondUser = item2.getPoint() ? 0 : 1;
return first - second; // Ascending
}); // using JAVA 1_8
。
html文件:
$def with(greeting)
然后更改:
app.py:
$def with(greeting)
<html>
...
</html>
...