Python handler(request)

在用python搭建服務器時有一個東西(姑且叫他東西吧)始終不得其解,今天查其他東西時偶然間發現了相關定義,可能存在理解不對的地方

來源爲aiohttp的官方文檔

這是原文中所說

coroutine handler(request)

Abstract method performing web-handler processing.

Parameters:request – aiohttp.web.Request instance for resolving, the request has aiohttp.web.Request.match_info equals to None at resolving stage.
Returns:aiohttp.web.StreamResponse or descendants.
Raise:aiohttp.web.HTTPException on error


翻譯過來也就是說:

handler(request)是一個協程函數,是處理web-handler過程的抽象函數,而web-handler指的是返回http相應的端點。

參數:request:用來解析的aiohttp.web.Request實例,在解析時aiohttp.web.match.info=None

返回:aiohttp.web.StreamResonse或descendants

若有錯則:raise aiohttp.web.HTTPExecption


發佈了28 篇原創文章 · 獲贊 26 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章