はじめに
以下のファイルをherokuで使用する場合は、エンコードの選択は必ずUTF-8(BOM無し)を選択してください。
- ‘Procfile‘
- ‘requirement.txt‘
- ‘runtime.txt‘
作成方法
(1) herokuへログインする
heroku login
(2) アプリを作成する
heroku apps:create line-stock-price
(3) Build Packを追加する
heroku buildpacks:add heroku/python -a <アプリ名>
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-google-chrome -a <アプリ名>
heroku buildpacks:add https://github.com/heroku/heroku-buildpack-chromedriver -a <アプリ名>
(4) requirements.txtを作成する
* pip freeze > requirements.txt
コマンド一覧
Gitの初期ファイル作成
git init
-
heroku git:remote -a <アプリ名>
変更したファイルをインデックスに登録
git add .
コミットを実施する
git commit -m "commit_message"
リモートリポジトリへのプッシュを実施する
git push heroku master
gitログ確認
git log
git status確認
git status
heroku上でプログラム実行
heroku run python main.py
Gitコマンドまとめ
- ローカルの特定のファイルをを元に戻す
git checkout <filename>
- ローカルの全てのファイルを元に戻す
git checkout .
- ローカルのbranch一覧確認コマンド
- 'git branch'
以下のサイトが参考になります。
【Python】herokuへデプロイしLINE通知する方法│初心者 / https://nkmrdai.com/python-heroku-linenotify/