python+搭建一个web
1.import web
pip install web.py==0.40.dev0
下载好后,修改
将第526行的
yield next(seq)1
修改为
try: yield next(seq) except StopIteration: return
2.建一个启动py
import web urls = ( '/(.*)', 'hello' ) app = web.application(urls, globals()) class hello: def GET(self, name): return open(r'test.html','r').read() if __name__ == "__main__": app.run()
3.写一个页面
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Run test</title> </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>
4.运行文件