Blog Cover Image

Inspire you to have New thinking, Walk out your unique Road.

[DEVELOP]PYTHON/DJANGO 之REST API開發(3)

Posted onApr 26, 2018

寫程式,有一個很重要的觀念

就是

Do by learn

千萬不要去買什麼書回來看,直接就上機然後自己規劃,不會就找網路跟問人!!

這是昨天早上突然天打雷劈想到的

然後趕緊把它畫下來 QQ

目前規劃是一樣使用 Django

只不過 Templates 的部分就變成是 Desktop App 在桌機端作為收集以及發送端

原本做表單跟收集資料的 Templates 網站就改成 Desktop App 端

這麼一來我就可以先利用 Templates 做開發測試,然後寫 Views/Model 做測試

之後在去開發桌機端那邊將 Templates 的功能套過去連接就行了!

所以我先將 Server 端搞定! 使用技術為 Django/Python


Html - Input file

https://www.w3schools.com/jsref/dom_obj_fileupload.asp


Python 多行註解

這裡是程式碼

這裡是程式碼 """

Python 單行註解


SQL

Python 3 >> PyMySQL

Python 2 >> MySQLdb


首先,先利用原生的 MVT 架構,先利用 Templates 網頁暫時當作 Desktop App 端

然後寫 Model 跟 View 去測

這裡有網頁參考:

http://dokelung-blog.logdown.com/posts/220833-django-notes-7-forms

Html - Input file

https://www.w3schools.com/jsref/dom_obj_fileupload.asp

這裡有幾個是關於寫 Views 的網站可以參考:

介紹 Request-response 用法

https://docs.djangoproject.com/en/2.0/ref/request-response/

介紹 Requests 用法

http://docs.python-requests.org/zh_CN/latest/user/quickstart.html


看起來像是客戶端 app 的 Python SQL 寫法

http://www.th7.cn/Program/Python/201709/1250178.shtml

Templates 接收 data,如何在 Views 將資料寫入資料庫

https://stackoverflow.com/questions/35602049/how-to-insert-data-to-django-database-from-views-py-file

https://stackoverflow.com/questions/23560665/how-to-insert-data-into-table-using-django

https://docs.djangoproject.com/en/2.0/ref/models/instances/

https://docs.djangoproject.com/en/1.11/intro/tutorial01/

先記錄到這.... 明天再繼續研究將資料回送給資料庫

只要這完成了

之後就可以繼續回去開發 Client 端-桌機程式


另外紀錄幾個遇到的小問題

Html - Input file

https://www.w3schools.com/jsref/dom_obj_fileupload.asp


Python 多行註解

這裡是程式碼

這裡是程式碼 """

Python 單行註解


SQL

Python 3 >> PyMySQL

Python 2 >> MySQLdb