首页 > 编程语言 > 详细

python开发web-入门html(一)

时间:2020-01-06 18:17:09      阅读:77      评论:0      收藏:0      [点我收藏+]
<html>
<head>
  <title>Hello</title>
  <style>
    h1 {
      color: #333333;
      font-size: 48px;
      text-shadow: 3px 3px 3px #666666;
    }
  </style>
  <script>
    function change() {
      document.getElementsByTagName(h1)[0].style.color = #ff0000;
    }
  </script>
</head>
<body>
  <h1 onclick="change()">Hello, world!</h1>
</body>
</html>

hello.py

# hello.py

def application(environ, start_response):
    start_response(200 OK, [(Content-Type, text/html)])
    return [b<h1>Hello, web!</h1>]
def application2(environ, start_response):
    start_response(‘200 OK‘, [(‘Content-Type‘, ‘text/html‘)])
    body = ‘<h1>Hello, %s!</h1>‘ % (environ[‘PATH_INFO‘][1:] or ‘web‘)
    return [body.encode(‘utf-8‘)]

server.py

# server.py
# 从wsgiref模块导入:
from wsgiref.simple_server import make_server
# 导入我们自己编写的application函数:
from hello import application

# 创建一个服务器,IP地址为空,端口是8000,处理函数是application:
httpd = make_server(‘‘, 8000, application)
print(Serving HTTP on port 8000...)
# 开始监听HTTP请求:
httpd.serve_forever()

python开发web-入门html(一)

原文:https://www.cnblogs.com/ljy1227476113/p/12157605.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!