restfull api 和 web框架的區別
1 回答

largeQ
TA貢獻2039條經驗 獲得超8個贊
函數必須帶兩個參數
request:表示請求的數據 默認帶以下屬性
headers: 頭部 (字典)
form: multipart/form表單 (字典)
getdic: url參數 (字典)
postdic: httpbody參數 (字典)
rfile: 原始http content內容 (字符串)
action: python文件名 (這里為example)
method: 函數方法 (這里為tt)
command: (get or post)
path: url (字符串)
http_version: http版本號 (http 1.1)
response_head: 表示response內容的頭部
例如如果要返回用gzip壓縮
則增加頭部
response_head["Content-Encoding"] = "gzip"
下載文件
默認靜態文件放在static文件夾下
例如把a.jpg放到static文件夾下
訪問的url為 http ://ip:port/static/a.jpg
支持etag 客戶端緩存功能
支持range 支持斷點續傳
(server 使用sendfile進行文件發送,不占內存且快速)
支持網頁模板編寫
創建一個模板 template.html
<HTML>
<HEAD><TITLE>$title</TITLE></HEAD>
<BODY>
$contents
</BODY>
</HTML>
添加回答
舉報
0/150
提交
取消