<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # web.py [TOC] ## 安裝 ``` pip3 install db pip install utils git clone https://github.com/webpy/webpy.git cd webpy python setup.py install pip list 查看是否添加了webpy ``` ## 入門 code ``` import web render =web.template.render("template") urls = ( '/index', 'index', '/blog/\d+', 'blog', '/(.*)', 'hello', ) app = web.application(urls, globals()) class hello: def GET(self, name): return "<html>hello word</html>" if __name__ == "__main__": app.run() ``` ### 模版 def GET(self, name): return open('./hello.html','r').read() ### URL映射 urls = ( '/index', 'index', '/blog/\d+', 'blog', '/(.*)', 'hello', ) ### 請求處理 ```python #請求參數 #地址:http://127.0.0.1:8080/index?name=cpj&age=13 class index: def GET(self): query = web.input() return query #輸出 <Storage {'age': '13', 'name': 'cpj'}> ``` ### 響應處理 #### 模版文件讀取 ``` #python文件 import web render =web.template.render("template") urls = ( '/(.*)', 'hello', ) app = web.application(urls, globals()) class hello: def GET(self, name): return render.hello1(name) #hello1 與template下的hello.html相同 if __name__ == "__main__": app.run() # hello1.html文件 $def with(name) <input type="text" name="username" value="$name"> ``` #### 結果數據獲取 ```python config = {'host': '127.0.0.1', 'port': 3306, 'user': 'root', 'password': 'root', 'db': 'imooc_o2o', 'charset': 'utf8mb4', 'cursorclass': pymysql.cursors.DictCursor, } class article: def GET(self): db = pymysql.connect(**config) #導入配置 cursor = db.cursor() cursor.execute("select `name`,`create_time` from `o2o_category`") results = cursor.fetchall() db.close() cursor.close() return render.article(results) #article.html模版 $def with(r) <h1>文章列表</h1> <ul> $for l in r: <li>$l['name']=>$l.get('create_time')</li> </ul> ``` > `l.['name']`與`l.get('name')` 效果相同
                  <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>

                              哎呀哎呀视频在线观看