first.py
这个文件中的代码为:
import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())
class hello:
def GET(self, name):
return open(r'1.html','r').read()
if __name__ == "__main__":
app.run()
然后是1.html,这个里的代码为:
<html>
<head>
<title>hello</title>
<script type="text/javascript">
function show_text(id,text){
document.getElementById(id).innerHTML=text;
}
function show_color(id,color){
document.getElementById(id).style.color=color;
}
</script>
<style type="text/css">
div p {color: #f00;}
.py{font-size: 40px;}
#l1{width: 200px;font-size: 40px;}
</style>
</head>
<body>
<h1>hello</h1>
<div>
World
</div>
<p class="py">
python
</p>
<label id="l1">
test
</label>
<div>
<a href="javascript:void(0);" onclick='javascript:show_text("l1","my first Javascript");'>My First Javascript</a>
<a href="javascript:void(0);" onclick='javascript:show_text("l1","Hello Python");'>Hello Python</a>
<a href="javascript:void(0);" onclick='javascript:show_color("l1","#f00") '>red</a>
<a href="javascript:void(0);" onclick='javascript:show_color("l1","#0f0") '>green</a>
</div>
</body>
</html>
然后你可以进行将这两个文件放在一个文件夹中。就可以利用python工具进行运行了。