? ?先學習learn python the hard way ?, 習題50中的課程。
? ?跟著銷售學python系列,是一個以時間軸為學習,和技能知識介紹的書籍。?
? ?跟著銷售學python ?num : ? 時間軸。
? ? 微信公共平臺開發-- 技能軸。
? ?遺留問題: 1,class index ,index2 命名隨便,甚至可以homepage: 怎么和之前index對應,或者兩者其實沒關系。
? 知識點:1、連續創建文件夾 ?mkdir
? ? ? ? ? ? ? ?2、項目布局的知識點回顧
? ? ? ? ? ? ? ? 3,如何執行py(在項目布局中)
? ? ? ? ? ? ? ? 4, 回顧__init__.py
? (1) 進入虛擬環境,安裝lpthw框架。
? ? source ?vne/bin/active
? ? ?pip ?install lpthw.web
? (2)建立項目框架
? ? ?mkdir ? lpthwweb ?docs tests bin?
? ? ? touch ?lpthwweb/__init__.py?
? ? ? ?touch ?bin/__init__.py
? ? ?(3) 建立一個web服務器
#導入web
? ? ? ? ? import web
#建立 / 與 Index ,當有人訪問網站根目錄,給他一個index頁面,匹配關系
? ? ? ? ? urls = ('/' ,'Index')
# 調用web,application的方法。globals()是python中記錄全局變量,返回字典。
? ? ? ? ? app =web.appliaction (urls,globals())
#定義Index
? ? ? ? ? ?class Index:
#get調用。
? ? ? ? ? ? ? ? def GET(self):
? ? ? ? ? ? ? ? ? ? greeting = 'hello world'
? ? ? ? ? ? ? ? ? ? ?return greeting
? ? ? ? ? if ?__name__ = '__main__' :
? ? ? ? ? ? ? ? app.run()
? ? ?保存app.py保存在bin中。
? ?運行瀏覽器: localhost:8080/
? ?發現,瀏覽器顯示hello world.
? ? 修改app.py任一內容,在刷新瀏覽器,看看各種錯誤,有個大概的概念。
? ? 如更改了,請control+c 在終端先停止運行,在打開。
? ? (4) ?
? ? ? ? ? ? ? ??
?