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.運行文件


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM