安裝Python的web.py框架并從hello world開始編程
最近有一個小的web項目,想用喜愛都python,但是想到之前接觸過都django我感覺一陣不寒而栗,為什么?Django的配置太過復雜,而且小項目不太適合MVC的開發(fā)模式,所以我將目光轉向了web.py這個小型web框架,并且真正讓我動心都是其官方網站上都一句話:"Django lets you write web apps in Django. TurboGears lets you write web apps in TurboGears. Web.py lets you write web apps in Python." — Adam Atlas
最近切換了Ubuntu替換了Win7系統(tǒng),所以這里介紹下Ubuntu都安裝web.py
安裝easy_install
sudo apt-get install python-pip
使用easy_install安裝web.py
sudo easy_install web.py
測試是否安裝成功:
在python shell中執(zhí)行:
import web
如果沒有報錯則web.py安裝成功. 下面開始我們第一個hello,world
import web
urls = ("/.*", "hello") # 指定任何url都指向hello類
app = web.application(urls, globals()) # 綁定url
# 定義相應類
class hello:
def GET(self):
return 'Hello, world!'
if __name__ == "__main__":
app.run()
然后保存為hello.py并運行它
python hello.py
然后會看到輸出:http://0.0.0.0:8080/
然后瀏覽器訪問:http://localhost:8080即可看到 Hello, world! 我們第一個用python寫的web程序就建立完成.
- python?web.py啟動https端口的方式
- python3.x中安裝web.py步驟方法
- python web.py開發(fā)httpserver解決跨域問題實例解析
- 淺析Python的web.py框架中url的設定方法
- Linux系統(tǒng)上Nginx+Python的web.py與Django框架環(huán)境
- 詳細解讀Python的web.py框架下的application.py模塊
- 使用Python的web.py框架實現類似Django的ORM查詢的教程
- Python開發(fā)WebService系列教程之REST,web.py,eurasia,Django
- python web.py服務器與客戶端的實現示例
相關文章
python 對任意數據和曲線進行擬合并求出函數表達式的三種解決方案
這篇文章主要介紹了python 對任意數據和曲線進行擬合并求出函數表達式的三種解決方案,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2020-02-02

