<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 功能強大 支持多語言、二開方便! 廣告
                現在,ORM框架、Web框架和配置都已就緒,我們可以開始編寫一個最簡單的MVC,把它們全部啟動起來。 通過Web框架的`@get`和ORM框架的Model支持,可以很容易地編寫一個處理首頁URL的函數: ~~~ @get('/') def index(request): users = yield from User.findAll() return { '__template__': 'test.html', 'users': users } ~~~ `'__template__'`指定的模板文件是`test.html`,其他參數是傳遞給模板的數據,所以我們在模板的根目錄`templates`下創建`test.html`: ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Test users - Awesome Python Webapp</title> </head> <body> <h1>All users</h1> {% for u in users %} <p>{{ u.name }} / {{ u.email }}</p> {% endfor %} </body> </html> ~~~ 接下來,如果一切順利,可以用命令行啟動Web服務器: ~~~ $ python3 app.py ~~~ 然后,在瀏覽器中訪問`http://localhost:9000/`。 如果數據庫的`users`表什么內容也沒有,你就無法在瀏覽器中看到循環輸出的內容。可以自己在MySQL的命令行里給`users`表添加幾條記錄,然后再訪問: ![2015-06-25/558ba1ce096bc](https://box.kancloud.cn/2015-06-25_558ba1ce096bc.png) ### 參考源碼 [day-07](https://github.com/michaelliao/awesome-python3-webapp/tree/day-07)
                  <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>

                              哎呀哎呀视频在线观看