網路是一條線 電腦的一切就像電流 這些小設備 0101 電腦之間可以溝通是因為電流的傳送 網路線連接 wifi web1.0很久以前的網頁 伺服器那端給我什麼就只能看什麼 不能有互動 web2.0 client端和sever之間可以有互動 >http協定(就像是文件) 不管在clinet to sever 東西送過來 80port 來溝通 服務窗口 銀行窗口都有他的編號 要互相溝通的話,你就可以去窗口說我要去銀行那個窗口 當你新買一台電腦,你沒有wifi 請動自己電腦的窗口 :8080叫代表port -![](https://i.imgur.com/YJIV6rW.jpg) # Webhook ## API VS Webhook >When using an API to get data from a server, the client requests the data and the server sends it back. API就像是,你有向它要求,他才會回覆給你東西 > The client has no idea if there is any new data or the status of the information on the server until it makes the request. 如果你沒有向API說你要什麼 像比之下Webhooks >Webhooks are the opposite. The server knows what information the client needs, and it sends it to the client as soon as it has some new data. The client then sends back a “thanks :)” also known as an HTTP “200 OK” acknowledgment to let the server know that the request was received and that there is no need to try to send it again. > ![](https://i.imgur.com/ikbgvvC.png) ## 框架 框架的好處: 框架的優點在於每次網頁開發可能會需要使用新增、修改、刪除等等 基本上你不可能手刻一個新增刪除的東西。框架就可以很方便的幫你, 舉例:像是如果你要新增你可以打add meber之類的,框架就可以幫助你完整的建立出一個資料庫然後新增資料之類的。 比較Django和Flask,兩者都是基於python來寫的 | 比較功能 | Django | Flask | | ---------- | -------------------------------------- | ------ | | 輕重量級別 | 重量級框架(相較比較多功能) | 較輕量 | | 入門程度 | 相較比較難入門 | 相較易入門 | | 官方文件 | 官方開發文檔更加詳細、完善、可讀性強。 | |