== 题目要求 == 写一个Hello,template程序,使用模板来显示Hello,{name},其中name是变量,要由外部传入 == 框架说明 == web.py (http://webpy.org) == 步骤 == 在命令行下操作 === 1. 创建Project2项目 === {{{ mkdir project2 }}} === 2. 创建Hello App === {{{ cd project2 vi hello.py }}} {{{ #!python import web from mako.template import TemplateLookup lookup = TemplateLookup('templates') def render(template, **kwargs): return lookup.get_template(template).render(**kwargs) urls = ('/', 'hello') class hello: def GET(self): return render('hello.mako', name='template') app = web.application(urls, globals()) if __name__ == '__main__': app.run() }}} === 4. 创建模板文件 === {{{ cd project2 mkdir templates vi hello.mako }}} {{{ Hello World

Hello, ${name}

}}} === 5. 结束 === == 测试 == {{{ cd project2 python hello.py }}} 访问 http://localhost:8080 即可。