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()
  • 相关阅读:
    CF1175B Catch Overflow!
    震惊!一蒟蒻竟然写出fhqTreap
    树上差分
    洛谷 P3128 最大流Max Flow
    线段树的标记永久化/二维线段树模板
    矩阵加速~desire drive
    置换相关
    树形图们
    严格单调递增与非严格之间的转换
    记录延续性的一类dp
  • 原文地址:https://www.cnblogs.com/wanglinjie/p/9320774.html
Copyright © 2011-2022 走看看