AI LINE Bot練功坊-L13 LineBot部屬 === ## 專案資料 ### 可上傳的 1. `app.py` 主要要執行的程式 :::warning :warning: 由於`vercel`中 `python` 版本的`handler`會和`app.py`中的`handler`互相衝突,所以要將`app.py`中的`handler`換成`line_handler` ::: 錯誤訊息  >Reference:https://www.wongwonggoods.com/all-posts/python/python-misc/python-debug-error/vercel-if-not-issubclass-basehttprequesthandler/ 2. `requirements.txt` 放寫程式有用到的套件,雲端才會知道要安裝哪些套件 3. `vercel.json` vercel的設定檔 連接vercel來將程式部屬在雲端執行 ```json { "version": 2, "builds": [ { "src": "app.py", "use": "@vercel/python" } ], "routes": [ { "src": "/(.*)", "dest": "app.py" } ] } ``` ### 不能上傳的 1. `.env` 放置重要的key以及token的地方,這些敏感的資訊不能直接放在主程式(`app.py`)中,而且這個檔案的內容**不能外流**,否則就危險了 ## Github 1. 建立repository  2. 建完後選擇add file,然後選upload files  3. 選擇choose your file後,把剛剛Echo-Bot中的` app.py`、`requirements.txt`以及`vercel.json`上傳到repository,並且在上船完成後進行commit   ## Vercel 1. 註冊帳號(與剛才的github連動) 2. import專案  3. 設定專案名稱以及環境變數  環境變數就是linebot的channel access token以及channel secret  ps. 如果之後有新的env要上傳,在project中找到setting,然後找到Environment Variable,下面有一個improt`.env`,將新的`.env`上傳即可  4. 設定完成後就進行部屬  5. 部屬完成後就點擊continue to dashboard  6. 複製紅框中的連結  7. 把連結貼到linebot的webhook url上,後面要加上/callback  8. 點擊verify後出現以下畫面就代表成功部屬  Youtube 課程影片 --- <iframe width="560" height="315" src="https://www.youtube.com/embed/rS6sEE4BBIE?si=gc27U-xahNjfE5t5" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> {%hackmd @ntuebigdata/about %} ## 相關教材連結 <div style="display: flex; justify-content:space-between;"> <div> <a class="btn btn-warning" href="https://hackmd.io/@ntuebigdata/rich-menu" style="color:white;width:300px;text-overflow:ellipsis;overflow:hidden">◀◀◀ L12 Rich Menu ◀◀◀</a> </div> <div> <a class="btn btn-info" href="https://hackmd.io/@ntuebigdata/azure-basic-introduction" style="color:white;width:300px;text-overflow:ellipsis;overflow:hidden">▶▶▶ L14 Azure 基本介紹 ▶▶▶</a> </div> </div>
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up