Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
635
20
HTTP 網路服務
當一個瀏覽器(browser,或任何其他的 web 客戶端)向一個伺服器
server)請求一個頁面(page),伺服器可能會回傳靜態或動態的內容。
動態內容的提供,需要伺服端 web 程式設計師即時產生並遞送內容,通常
是基於儲存在資料庫中的資訊。
web 的史前時代,伺服端程式設計的標準是
CGI
Common Gateway
Interface),它要求伺服器每次接收到客戶端請求動態內容時都要執行一個
個別的程式。行程起始時間、直譯器的初始化、連接資料庫,以及指令稿
script)的初始化,這些加起來是不小的額外負擔(overhead)。因此,
CGI 並不容易拓展規模。
今日,web 伺服器支援許多伺服器專用的方式來減低額外負擔,從能夠服
務多個請求的行程提供動態內容,而非為每個請求都啟動一個新的 CGI
程。因此,我們沒有在本書中涵蓋 CGI。要維護既存的 CGI 程式,或將它
們移植到更現代的做法,請參閱標準程式庫模組
cgi
https://docs.python.
org/3/library/cgi.html
)和
http.cookies
https://docs.python.org/3/library/http.
cookies.html
)的線上文件
1
1 CGI 有遺留下來的一個傳統:當時伺服器主要是透過作業系統的環境(在 Python 中,
那是
os.environ
)提供要服務的 HTTP 請求之相關資訊給 CGI 指令稿,直到今日,web
伺服器和應用程式框架之間的介面還是仰賴「一個環境」 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819