次の Django のプログラムを Heroku にデプロイします。
Django で簡単なページ遷移をする
他のサイトからのアクセスを許可するように、proj01/settings.py を修正します。
proj01/settings.py
(省略)
ALLOWED_HOSTS = ['*']
(省略)
proj01 のフォルダーに次のファイルを作成します。
Procfile
runtime.txt
requirements.txt
フォルダーの構造
$ tree -L 1
.
├── app01
├── app02
├── db.sqlite3
├── home
├── manage.py
├── Procfile
├── proj01
├── requirements.txt
└── runtime.txt
Procfile
web: gunicorn proj01.wsgi --log-file -
runtime.txt
python-3.10.7
requirements.txt
django
gunicorn
Heroku にアップロードします。
heroku login -i
git init
git add .
git commit -m "init"
heroku create p0485
heroku config:set DISABLE_COLLECTSTATIC=1
git push heroku master
ブラウザーで
https://p0485.herokuapp.com/
にアクセスしてデプロイを確認
コンソールで実行を確認する方法
$ heroku ps
› Warning: heroku update available from 7.60.1 to 7.66.0.
▸ Starting November 28th, 2022, free Heroku Dynos will no longer be
▸ available. To keep your apps running, subscribe to Eco or upgrade to
▸ another paid tier. Learn more in our blog
▸ (https://blog.heroku.com/new-low-cost-plans).
Free dyno hours quota remaining this month: 548h 27m (99%)
Free dyno usage for this app: 0h 0m (0%)
For more information on dyno sleeping and how to upgrade, see:
https://devcenter.heroku.com/articles/dyno-sleeping
=== web (Free): gunicorn proj01.wsgi --log-file - (1)
web.1: up 2022/11/08 11:52:00 +0900 (~ 1m ago)