标签:blog http io os ar for 2014 div sp
这个例子你可以看到可以再模板中编写python代码,也会粗略的编写第一个web.py程序了。步骤如下。
1、首先看结构
2.在testquery2.py中输入:
import web
import os
class index:
def GET(self):
print "进入index"
render=web.template.frender("template/index2.html")
return render("sha-ya")
urls = ("/index2","index")
if __name__=="__main__":
print "begin"
# queryinfo()
app =web.application(urls,globals())
app.run()
print "over"
第三部:
在index2.html中
$def with (name)
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Template测试</title>
</head>
测试
<body>
<div>
Hi, $name
</div>
$#This is 注释
<div>---------------------------</div>
$for i in range(10):
line:$i
</body>
</html>
标签:blog http io os ar for 2014 div sp
原文地址:http://www.cnblogs.com/sha-ya/p/3981213.html