zoukankan      html  css  js  c++  java
  • wsgiref

    参考

    https://www.cnblogs.com/kuaizifeng/p/7618117.html

     1 def hello_world_app(environ, start_response):
     2     status = '200 OK' # HTTP Status
     3     headers = [('Content-type', 'text/plain')] # HTTP Headers
     4     start_response(status, headers)
     5  
     6     # The returned object is going to be printed
     7     return [b"Hello World"]
     8  
     9 def main():
    10     from wsgiref.simple_server import make_server
    11     httpd = make_server('', 8000, hello_world_app)
    12     print("Serving on port 8000...")
    13  
    14     # Serve until process is killed
    15     httpd.serve_forever()
    16  
    17 if __name__ == '__main__':
    18     main()
     1 # 从wsgiref模块导入:
     2 from wsgiref.simple_server import make_server
     3 
     4 # 导入我们自己编写的application函数:
     5 def application(environ, start_response):
     6     start_response('200 OK', [('Content-Type', 'text/html')])
     7     return [b'<h1>Hello, web!</h1>']
     8 
     9 # 创建一个服务器,IP地址为空,端口是8000,处理函数是application:
    10 httpd = make_server('127.0.0.1', 8000, application)
    11 print("Serving HTTP on port 8000...")
    12 # 开始监听HTTP请求:
    13 httpd.serve_forever()
  • 相关阅读:
    windows cmd command line 命令
    windows cmd color setup
    二进制中1的个数
    斐波拉契数列
    旋转数组的最小数字
    用两个栈实现队列
    重建二叉树
    Bootstrap学习笔记(三) 网格系统
    Bootstrap学习笔记(二) 表单
    Bootstrap学习笔记(一) 排版
  • 原文地址:https://www.cnblogs.com/wanglinjie/p/9320774.html
Copyright © 2011-2022 走看看