The interpretation of the Python Network Programming Learning Note (WEBPY): Framework (http://www.cnblogs.com/xiaowuyi/archive/2012/11/15/2771099.html#3006443).
Netizen @etfengyun recently raised doubt, webpy0.33 on the use of template error occurred. As I did not reproduce the error according to @etfengyun, so it is not good to judge the cause of the error, the concrete use of the template to explain the steps in detail.
1, Environment: python2.7.x+webpy0.33 (: http://webpy.org/static/web.py-0.33.tar.gz)
2. Create Test folder, The webpy0.33 extracted Web folder is placed under test, and the establishment of testwebpy.py file and the creation of Templates folder, under the Templates folder, the creation of index.html file, the file content is:
$def with (name) $if name: <em>hello</em> to $name. $ Else : <em>hello</em>, world!
3, the testwebpy.py code:
##@ Xiao Wu Yi Http://www.cnblogs.com/xiaowuyiImportWebrender= Web.template.render ('templates/') URLs= ( '/','Index')classIndex:defGET (self): name='Bob' returnRender.index (name)#return "Hello, world!"if __name__=="__main__": App=web.application (URLs, Globals ()) App.run ()
Operating effect:
Code Listing 2:
##@ Xiao Wu Yi Http://www.cnblogs.com/xiaowuyiImportWeb Render= Web.template.render ('templates/') URLs= ( '/(.*)','Index' ) classIndex:defGET (self,name): I=web.input (name=None)returnRender.index (name)#return "Hello, world!"if __name__=="__main__": App=web.application (URLs, Globals ()) App.run ()
Operating effect: