LoginSignup
7
7

More than 5 years have passed since last update.

HerokuでPythonアプリをデプロイしてみた

Last updated at Posted at 2019-02-23

Herokuのインストール

Herokuの会員登録をし、その後、Heroku CLIをインストールしてください。

3つのファイルの準備

Procfile

web: python main.py
requirements.txt
Flask==0.12.2
・・・

requirements.txtには自分が使用したモジュールの名前とversionを書いてください。
ターミナルでpip freezeをすると一覧が取得できます。

runtime.txt
python-3.6.8

Buildpacks

Herokuに移動し、SettingからAdd buildpackをクリックし、Pythonを選択してください。

デプロイ

次は、ターミナルで、デプロイしたいアプリのディレクトリまで行き、以下のコードを実行してください。

$ heroku login

会員登録をしたメールアドレスとパスワードを入力してください。

$ heroku create アプリ名
$ git init(これは初回のみです)
$ heroku git:remote -a (アプリ名)

これでGitリポジトリが作成されたので、初期設定をします。

$ git add .
$ git commit -m “(何を変更したかメッセージを書く)”
$ git push heroku master

これでデプロイ完了です。

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7