[DAY8]将范例上传(2)

第一步:将昨天下载完的压缩档解压缩,取出line-bot-sdk-python-master\examples中的flask-echo资料夹将其中资料和Linebot资料夹转移至我们创立的资料夹
https://ithelp.ithome.com.tw/upload/images/20210922/20140159LWHlc8pCoU.png
https://ithelp.ithome.com.tw/upload/images/20210922/201401598lTocGCyF2.png
第二步:编辑app.py
https://ithelp.ithome.com.tw/upload/images/20210922/20140159DO6Y97H5Aw.jpg
更改红框内的内容将其改成在LINE提供的channel_secret和channel_access_token(可於LINE Developer寻找),於def callback副程序内加上print(body)
将flask,future,requests, line_bot_sdk,gunicorn, psycopg这些字串放入requirements.txt档里面让Heroku记得下载
https://ithelp.ithome.com.tw/upload/images/20210922/20140159Tx7lmtTUi3.png
第三步:回到CMD

  1. 输入heroku login
    https://ithelp.ithome.com.tw/upload/images/20210922/20140159sztLXzOOg6.png
    按下Log in後关闭
  2. 输入heroku git:remote -a {Heroku专案名}
  3. 输入git init
  4. 输入git add .
  5. 输入git commit -am'ok'
  6. 最後输入git push heroku master
PS F:\课业\juclinebot\juctest> heroku login
 »   Warning: heroku update available from 7.53.0 to 7.56.1.
heroku: Press any key to open up the browser to login or q to exit: 
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/acc9faa8-807c-49c3-aad3-df1f897d13c3?requestor=SFMyNTY.g2gDbQAAAA4xMTguMTUwLjEyNS42NG4GADCf_Qp8AWIAAVGA.UxxAOnDfwa6LFXrKpiyhZzod7g7PE1m94BbzcfUJioY
Logging in... done
Logged in as [email protected]
PS F:\课业\juclinebot\juctest>
PS F:\课业\juclinebot\juctest> heroku git:remote -a juctest
 »   Warning: heroku update available from 7.53.0 to 7.56.1.
set git remote heroku to https://git.heroku.com/juctest.git
PS F:\课业\juclinebot\juctest> git init
PS F:\课业\juclinebot\juctest> git add .
PS F:\课业\juclinebot\juctest> git commit -am'ok'
[master 8ede0b8] ok
 Committer: cscs020 <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)
PS F:\课业\juclinebot\juctest> git push heroku master      
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 390 bytes | 390.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the same version as the last build: python-3.9.6
remote:        To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote:  !     Python has released a security update! Please consider upgrading to python-3.9.7
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> No change in requirements detected, installing from cache
remote: -----> Using cached install of python-3.9.6
remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 57.6M
remote: -----> Launching...
remote:        Released v76
remote:        https://juctest.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/juctest.git
   a14adf9..8ede0b8  master -> master

第四步:回到LINE Developer更改webhook
改成https://{hereku专案名}.herokuapp.com/callback
https://ithelp.ithome.com.tw/upload/images/20210922/20140159kVtf3hnAHZ.jpg
将Use webhook打开,关闭Auto-reply messages 。
第五步:拿起LINE扫描QRcode将机器人加入好友并传送讯息
https://ithelp.ithome.com.tw/upload/images/20210922/20140159KVnGnrdp4R.png
成功QAQ
参考资料:
LINE Bot聊天机器人程序开发教学(二):注册与设定Heroku平台应用程序 - 超图解系列图书
使用 Heroku 建立范例聊天机器人 | LINE Developers
LineBot+Python,轻松建立聊天机器人 | BlackMaple's Blog
(376) 【Maso的万事屋】10分钟用Python做LineBot聊天机器人|程序设计 - YouTube


<<:  CSS微动画 - Loading来了!时钟转转转

>>:  食谱资料库架构图

Day10: Detection on AWS

接下来我们将进入到五大面向的第二个部分:侦测。 侦测帮你找出资源的错误配置以及异常的行为,这些找到的...

[面试][人格特质]当你分享工作经验时会被问到的种种问题

每个人都有自己的人生经验,本篇文章是从笔者的角度出发,希望可以给读者带来不同的视角与观点。 从第二...

【Day20】:Servo控制-By PWM输出

Servo 对於简单的角度控制,大家第一个想到的就是伺服马达了吧,大小也适中,非常适合用在机器人上。...

Day16-策略不只用在兵法 什麽是策略(Strategy)

前一章介绍了Deployment如何建立,以及产生ReplicaSet後,可以看到pod是怎麽被建立...