<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                #### 框架的代碼 ~~~ #! /usr/bin/env python # -*- coding:utf-8 -*- ''' @Time: 5/2/183:44 AM @Author:haibo @File: ctime.py ''' import time # from MyWebServer import HTTPServer HTML_ROOT_DIR = "./wwwroot" class Application(object): """Web框架的核心部分,也就是框架的主體程序,框架是通用的""" def __init__(self, urls): # 設置路由信息 self.urls = urls def __call__(self, env, start_response): path = env.get("PATH_INFO", "/") # 判斷路徑 # /static/index.html if path.startswith("/static"): # 要訪問靜態文件 file_name = path[7:] # 打開文件,讀取內容 try: file = open(HTML_ROOT_DIR + file_name, "rb") except IOError: status = "404 Not Found" headers = [] start_response(status, headers) return "not found" else: file_data = file.read() file.close() status = "200 OK" headers = [] start_response(status, headers) return file_data.decode("utf-8") for url, handler in self.urls: if path == url: return handler(env, start_response) # 代表未找到路由信息,404錯誤 status = "404 Not Found" headers = [] start_response(status, headers) return "not found" def show_time(env, start_response): status = "200 OK" headers = [ ("Content-Type", "text/plain") ] start_response(status, headers) return time.ctime() def say_hello(env, start_response): status = "200 OK" headers = [ ("Content-Type", "text/plain") ] start_response(status, headers) return "hello haibo" url = [ ("/", show_time), ("/ctime", show_time), ("/sayhello", say_hello), ] # 把自身當做對象給APP app = Application(url) # app = Application(url) # http_server = HTTPServer(app) # http_server.bind(8002) # http_server.start() ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看