Python 2.7 已終止支援,並將於 2026 年 1 月 31 日
淘汰。淘汰後,您將無法部署 Python 2.7 應用程式,即使貴機構先前曾使用機構政策重新啟用舊版執行階段的部署作業,也無法部署。現有的 Python 2.7 應用程式在
淘汰日期過後,仍會繼續執行並接收流量。建議您
改用系統支援的最新 Python 版本。
webapp2 架構
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
注意:此架構僅適用於 Python 2.7 使用者。
網路應用程式架構可妥善處理介面的細節,進而簡化開發程序,讓您專注在應用程式功能的開發作業。App Engine 提供一套名為 webapp2 的簡易網路應用程式架構;您可以透過這個簡易的架構,快速建構適用於 Python 2.7 執行階段的簡易網路應用程式。
webapp2 與 Python 網路應用程式的 WSGI 標準相容。您不必使用 webapp2 編寫 App Engine 的 Python 應用程式。其他網路應用程式架構 (例如
Django) 可與 App Engine 搭配使用,而 App Engine 也支援任何使用 CGI 標準的 Python 程式碼。Rodrigo Moraes 的 webapp2 專案一開始是 App Engine webapp 架構的分支,該架構由 Python 2.5 執行階段使用。webapp2 包含多項可簡化網路應用程式開發作業的功能,例如改善 URI 路由、工作階段管理和本地化功能的支援。Python 2.7 執行階段使用的是 webapp2,而專案是在 App Engine 外部進行維護。Google 雖有提供支援,但並非由 Google 維護。
如要進一步瞭解 webapp2,請參閱官方說明文件。
在 Python 2.7 中使用 webapp2 架構
Python 2.7 應用程式可使用 WSGI 或 CGI 來處理要求,但通常建議使用 WSGI。
Blobstore 與郵件處理常式
webapp2 是外部程式庫,因此不提供任何 App Engine 專屬服務。Python 2.7 應用程式必須使用 BlobstoreUploadHandler
和 BlobstoreDownloadHandler
的 webapp 版本。詳情請參閱「webapp Blobstore 處理常式」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-04 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003ewebapp2 is a lightweight web application framework for Python 2.7, simplifying development by handling interface details and allowing developers to focus on application features.\u003c/p\u003e\n"],["\u003cp\u003ewebapp2 is compatible with the WSGI standard but not exclusive; other frameworks like Django are also supported, and any Python code using CGI works with App Engine.\u003c/p\u003e\n"],["\u003cp\u003eOriginally forked from the App Engine webapp framework used by the Python 2.5 runtime, webapp2 includes improved features such as better URI routing, session management, and localization.\u003c/p\u003e\n"],["\u003cp\u003eAlthough webapp2 is an external library and is supported but not maintained by Google, it does not provide any App Engine-specific services, so Python 2.7 apps must use webapp versions of \u003ccode\u003eBlobstoreUploadHandler\u003c/code\u003e and \u003ccode\u003eBlobstoreDownloadHandler\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# The webapp2 Framework\n\n**Note:** This framework is available to Python 2.7\nusers only.\n\nA web application framework can simplify development by taking care of the\ndetails of the interface, letting you focus development effort on your\napplication's features. App Engine includes a simple web application framework\ncalled [webapp2](https://webapp2.readthedocs.io/) - a lightweight\nframework that allows you quickly build simple web applications for the Python\n2.7 runtime.\n\nwebapp2 is compatible with the WSGI standard for Python web applications.\nYou don't have to use webapp2 to write Python applications for App Engine.\nOther web application frameworks, such as [Django](http://www.djangoproject.com/), work with App Engine, and App Engine supports any Python code that\nuses the CGI standard. The webapp2 project, by Rodrigo Moraes, started as a fork\nof the App Engine [webapp](/appengine/docs/legacy/standard/python/tools/webapp)\nframework, which was used by the Python 2.5 runtime. webapp2 includes a number\nof features that make developing web applications easier, such as improved support\nfor URI routing, session management and localization. The Python 2.7 runtime uses\nwebapp2, and the project is maintained externally to App Engine. It is supported,\nbut not maintained, by Google.\n\nFor more information about webapp2, see the\n[official documentation](https://webapp2.readthedocs.io/).\n\nUsing the webapp2 framework in\nPython 2.7\n-----------------------------------------\n\nPython 2.7 applications can use either WSGI or CGI to handle requests, but WSGI\nis generally recommended.\n\nBlobstore and Mail Handlers\n---------------------------\n\nSince it is an external library, webapp2 does not provide any App Engine-specific\nservices. Python 2.7 apps must use the webapp versions of\n`BlobstoreUploadHandler` and `BlobstoreDownloadHandler`.\nSee [webapp\nBlobstore Handlers](/appengine/docs/legacy/standard/python/tools/webapp/blobstorehandlers) for details."]]