---
# System prepended metadata

title: 'Cancer cellbank and NFT(T-03,T-04)'

---

# Cancer cellbank and NFT(T-03,T-04)
---

## cellbank website

###  PostgreSQL
#### Create a PostgreSql database 相關指令

![](https://i.imgur.com/nFBktUo.png)

----
#### PGadmin4
![](https://i.imgur.com/hk7CP8m.png)

* 觀念流程圖

----
![](https://i.imgur.com/F1r2R64.png)
* 成功將DB中的數值存取成功
----
![](https://i.imgur.com/c5DDgVQ.png)
* [PGadmin4 資料庫更新慢解決方式](https://stackoverflow.com/questions/43963403/pgadmin4-is-very-slow-to-open-empty-tables-of-database)

----
#### Project ongoing
----
##### flask website
* framework:flask
* backend language:python 3
* DB:postgreSQL
----
###### pipenv 實作
* [pip install易錯問題 下載時就要在變數環境中改動](https://stackoverflow.com/questions/64511066/python-3-9-pip-install)
* 如以下圖
![](https://i.imgur.com/CypmklX.png)

----
* pipenv安裝成功
![](https://i.imgur.com/5vhmgtL.png)
* flask安裝成功
![](https://i.imgur.com/nAZZOx1.png)
![](https://i.imgur.com/C4I0lJ7.png)

* psycopg2 安裝
![](https://i.imgur.com/MVT5sgt.png)

* flask-sqlalchemy安裝
![](https://i.imgur.com/cMxfcvb.png)

* gunicorn安裝--->之後若要 deploy 到 ==heroku== 需要用到
![](https://i.imgur.com/zZaUHv6.png)



----
* [pipenv管理套件工具使用](https://medium.com/@chihsuan/pipenv-%E6%9B%B4%E7%B0%A1%E5%96%AE-%E6%9B%B4%E5%BF%AB%E9%80%9F%E7%9A%84-python-%E5%A5%97%E4%BB%B6%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7-135a47e504f4)
![](https://i.imgur.com/YE3uXJb.png)

---
### flask實作細節
####  flask安裝
* [flask基本介紹](https://ithelp.ithome.com.tw/articles/10222132)
----
#### flask應用架構
![](https://i.imgur.com/oahZxr8.png =x300)

----
#### flask連上伺服器
![](https://i.imgur.com/ul7AclB.png)

----
#### app get/post
![](https://i.imgur.com/dcBJzSY.png)

----
#### 網站程式測試server是否正常
![](https://i.imgur.com/ik47Hp0.png)

----
* 重新整理網站browser,會發給後端程式一個要求,後端程式會紀錄新的連線

![](https://i.imgur.com/xFye0TI.png)


* 後端程式按ctrl+c連線才會停下來
![](https://i.imgur.com/v1MPw6L.png)

* [How to setup environment variables for `flask run` on Windows?](https://stackoverflow.com/questions/51119495/how-to-setup-environment-variables-for-flask-run-on-windows)
---
#### Flask-SQLAlchemy 

* [使用documentaton](https://flask-sqlalchemy.palletsprojects.com/en/2.x/quickstart/)
* [ Flask-SQLAlchemy 資料庫操作](https://www.maxlist.xyz/2019/11/10/flask-sqlalchemy-setting/)
* 成功讓資料庫得到我從前端介面成功輸入的資料
    ![](https://i.imgur.com/KN6EMZU.png)
* Mailtrap 收到send_email.py寄送出的信(包含我在前端頁面寫下的資訊)
   ![](https://i.imgur.com/UmiQnJU.png =x200)
   ![](https://i.imgur.com/jih3EqL.png =x250)
* 同時pgADMIN4也可以看到資料庫裡多一筆剛傳入的資料
  ![](https://i.imgur.com/cNlFkqK.png)


---

### Heroku

* Flask網站架設--->deploy 到 heroku雲端主機

* 確定上架到heroku
![](https://i.imgur.com/ewjeZnO.png =x30)

![](https://i.imgur.com/nawNW6q.png)
* 從heroku上建好DB

![](https://i.imgur.com/mNQgKyj.png)

* 拿到production DB url

![](https://i.imgur.com/RAMIt4q.png =x40)

* 為了在heroku上啟動專案
  * 創建procfile使用gunicorn套件--->第一個參數:app.py取app 第二個參數固定打app 
![](https://i.imgur.com/CsvsHzW.png)
* 推到 heroku local repository
  
  ![](https://i.imgur.com/GFTFbdC.png =x300)

* 設定git remote
  
  ![](https://i.imgur.com/JDcII56.png =x60)
 
* 成功上架heroku masterbranch成功
  ![](https://i.imgur.com/5AwymPs.png =x80)


----

 
* ==常見問題== 
    * 如果當掉了,要重連pgADmin4中資料庫的連線,重新開啟--->卡關很久
      * ![](https://i.imgur.com/vh08ijN.png)
      * ![](https://i.imgur.com/kTXVLO7.png)
      * 回到server--->![](https://i.imgur.com/XF2vJnG.png =x30)
      * app.py連線到DB check有無schema table--->![](https://i.imgur.com/aMnMbfN.png =x400)
      
    * ==TypeError: __init__() takes 1 positional argument but 5 were given==--->![](https://i.imgur.com/ShdwW9C.png)

    * Heroku 卡很久 連不上(==未解決why??==)
       * ![](https://i.imgur.com/obLefp2.png)
    * Requested runtime (Python 3.9.6) is not available for this stack (heroku-20)
       * [stack overflow解法--->其實就小心runtime.txt大小寫因為case sensitive](https://stackoverflow.com/questions/57216239/requested-runtime-python-3-7-3-is-not-available-for-this-stack-heroku-18)
       ![](https://i.imgur.com/4vSBFit.png)

    * [The local psql command could not be located](https://devcenter.heroku.com/articles/heroku-postgresql#set-up-postgres-on-windows)
    ![](https://i.imgur.com/RMPah9E.png)


---
### 串 gmail API
![](https://i.imgur.com/ljD6wzr.png =x130)

![](https://i.imgur.com/NtZxLal.png =x130)

* [flask mail](https://pythonhosted.org/Flask-Mail/)

==寄送gmail通知==

### DB diagram
* [學習資料](https://dbdiagram.io/d)
### bitbucket
* [協作工具](https://bitbucket.org/shawn90830/cancerfree/create-file/6685fbfd0b95384e0940cd37cf09d1606d31de06/?at=master)
### get/post差別
* [get/post區別](https://totoroliu.medium.com/http-post-%E5%92%8C-get-%E5%B7%AE%E7%95%B0-928829d29914)
### python
#### __init__
* [  __ __init__ __ in Python](https://www.geeksforgeeks.org/__init__-in-python/)
* [繼承](https://www.geeksforgeeks.org/__init__-in-python/)
---
### Accepting Payments in Flask Using Stripe 
* [stripe API 串接金流](https://easonwang.gitbook.io/web_advance/jin-liu-chuan-jie/stripe-chuan-jie)
* [stripe API文件](https://stripe.com/docs/api)
* [stripe CLI](https://stripe.com/docs/development)
* [How to Run an EXE File From Command Prompt](https://www.wikihow.com/Run-an-EXE-File-From-Command-Prompt)
* [Install Stripe CLI on Windows 10 Using Scoop Windows Package Manager](https://www.youtube.com/watch?v=DTr2mLY_8gs)
* 在stripe上的拍賣產品
![](https://i.imgur.com/NY0ksCR.png)
* price api id
![](https://i.imgur.com/ddPsmdZ.png)


#### Final Goals
==用flask框架架站連結opensea 顯示cancerfree網站數量的增減==

---
## NFT
### NFT 基礎入門概念
* [實作NFT接到ERC-721公鍊 使用solidity](https://www.youtube.com/watch?v=YPbgjPPC1d0&t=968s&ab_channel=DappUniversity)
* [2021 快速建立 ERC721 標準智能合約並且 Mint NFT](https://yulinchou.medium.com/2021-%E5%BB%BA%E7%AB%8B-erc721-%E6%A8%99%E6%BA%96%E6%99%BA%E8%83%BD%E5%90%88%E7%B4%84-%E4%B8%A6%E6%89%93%E9%80%A0%E8%87%AA%E5%B7%B1%E7%9A%84-nft-99afaca68530)
* [智能合約 smart contract很好懂入門影片](https://www.youtube.com/watch?v=ZE2HxTmxfrI&ab_channel=SimplyExplained)
* [NFT很好懂4分鐘短片](https://www.youtube.com/watch?v=FkUn86bH34M&ab_channel=SimplyExplained)
* [乙太坊查閱文件](https://ethereum.org/en/developers/docs/intro-to-ethereum/)
* [中文版solidity好懂教學短片 建議1.5倍速觀看 ](https://youtu.be/z2FEikbDqoA)

### 實作紀錄
#### 在remix上實作第一份CancerFree.sol NFT
![](https://i.imgur.com/gvx1jyc.png)

----
#### 在IPFS(星際檔案系統)上 上傳第一份Cancercell
![](https://i.imgur.com/BW86LnS.png)

----
##### IPFS JSON檔
![](https://i.imgur.com/YvQTXx6.png)

----
#### 和faucet service乞討完付完0.4eth的gas fee 後
![](https://i.imgur.com/KGvAkPx.png)

----
#### Deploy 成功
![](https://i.imgur.com/7E5nk3k.png)

----
#### mint成功
![](https://i.imgur.com/36RaIlp.png)

----
#### 檢查有無出現在 rinkeby etherscan 上的 Transaction 網址
==若有-->代表成功mint==
![](https://i.imgur.com/ZaaqBN5.png)

#### 上架到opensea上囉
![](https://i.imgur.com/01XTMjR.png)



----
## 實作筆記(大家可以把心得打在上面)




----


## 留言區(問題討論)
* ![](https://i.imgur.com/dJthsGq.png =x40)
    * --->==編輯有問題的話可以按最上面那一排的"?"==
* ![](https://i.imgur.com/IpDIrrT.png =x100)
    * --->==內容有問題也可以按右上角的問號鍵 打下問題內容==   


## 未整理
Products內容較多 (不需要培養)
Guest,memeber,VIP
可以修改內容
中英文

react restfulAPI 
Postsgre 

有membership
功能可以買東西即可


會員買細胞 剩多少細胞 狀態如何

參考網站內容 著名文字

Shopping website
認知細胞網站construction

區塊鏈 data先放100顆癌病毒

ethereum ECR721
testify 
放到testnet上看到 cz001 ---> 10個copy的nft(publish 1個 image)

Drug screening 
Clinical


celline 名字 凍管 str 

opensea ipfsswarm