zoukankan      html  css  js  c++  java
  • python开发web-入门html(一)

    <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()
  • 相关阅读:
    Oracle Merge into
    查询 null 记录
    删除 eclipse 插件
    vs 密钥
    视频网站建设
    eclipse 版本 查看
    让数据库变快的十个建议
    c# WebBrowser 操作
    svn 代码合并
    Android开发者应该深入学习的10个开源应用项目
  • 原文地址:https://www.cnblogs.com/ljy1227476113/p/12157605.html
Copyright © 2011-2022 走看看