• 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()
  • 相关阅读:
    axios核心技术---1.HTTP相关
    Leetcode刷题
    Java入门13---Optional处理null对象
    Java入门12---Stream
    谈谈前后端分离及认证选择
    react监控props的变化
    如何使用懒加载
    CSS文字超出省略
    React的slot插槽
    React 的函数组件和类组件中的props
  • 原文地址:https://www.cnblogs.com/ljy1227476113/p/12157605.html
Copyright © 2020-2023  润新知