How to upload with Heroku, Flask, Python, Git (Part 2)

I learned about Heroku, Flask, and Python with Progate, dot install, Qiita, etc., so I will summarize them.

(1) Create a working directory (2) Set up a virtual environment (3) Install the necessary framework and WEB server (4) Create Flask file in Python (5) Try running the Flask file (6) Deploy to Heroku ① Register an account with Heroku ② Install Heroku with Homebrew ③ Prepare Git ④ Create an app on Heroku ⑤ Link the local app with the Heroku app ⑥ Create the files required for deployment to Heroku ⑦ Deploy to Heroku (7) Error handling ① Heroku ps: scale web = 1 is normal ② Heroku ps: scale web = 1 is not normal (8) Update the file

(6) Deploy to Heroku

① Register an account with Heroku

Go to the Heroku page below and register for a Heroku account. https://www.heroku.com/

② Install Heroku with Homebrew

First, install a package manager called Homebrew. Access the following Homebrew page, paste the displayed script into the terminal and execute it. https://brew.sh/index_ja

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then enter the following into your terminal to install Heroku.

brew install heroku/brew/heroku

Log in with the account you created earlier. スクリーンショット 2020-02-26 20.59.04.png

③ Prepare Git

For details on Git, refer to the following page. https://backlog.com/ja/git-tutorial/ https://prog-8.com/languages/git

Check the version of Git.

git version

If Git is installed, it will be as follows.

git version 2.20.1 (Apple Git-117)

To confirm the initial settings, enter the following respectively.

git config user.name
git config user.email

If nothing happens, register your name and email as shown in the example below. (If you don't register, Git won't work properly)

git config user.name "hogehoge"
git config user.email "[email protected]"

④ Create an app on Heroku

You need to connect the locally created hello.py app to Heroku (remote). First, log in to Heroku as follows.

heroku login

If the following is displayed, enter any character other than q to display the Heroku page.

Press any key to open up the browser to login or q to exit:

When you log in, you will see the screen below. スクリーンショット 2020-02-26 20.59.04.png

After that, in the terminal, in Heroku, as an example, create an application called sample-noonnoon, and enter the following.

 heroku create sample-noonnoon

The app is now created on Heroku. If you log in to the Heroku page and check the dashboard, you can see sample-noonnoon as shown below. スクリーンショット 2020-02-27 19.10.03.png

⑤ Link the local app with the Heroku app

Associate an app created locally with an app created on Heroku. First, initialize Git in my-project.

git init

Enter the following to check if it is really initialized. (OK if .git is displayed)

ls -a

By initializing Git, you can manage the change history in the directory my-projedt. Next, link Git and Heroku.

heroku git:remote -a sample-noonnoon

By doing this, the local app and the Heroku app will be linked.

set git remote heroku to https://git.heroku.com/sample-noonnoon.git

How to upload with Heroku, Flask, Python, Git (3)

Recommended Posts

How to upload with Heroku, Flask, Python, Git (Part 3)
How to upload with Heroku, Flask, Python, Git (Part 1)
How to upload with Heroku, Flask, Python, Git (Part 2)
How to upload with Heroku, Flask, Python, Git (4)
How to measure execution time with Python Part 1
How to measure execution time with Python Part 2
How to use python interactive mode with git bash
Python: How to use async with
How to use FTP with Python
How to calculate date with python
How to authenticate with Django Part 2
How to authenticate with Django Part 3
How to deploy a web app made with Flask to Heroku
How to upload files to Cloud Storage with Firebase's python SDK
How to work with BigQuery in Python
How to do portmanteau test with python
How to display python Japanese with lolipop
Easy web app with Python + Flask + Heroku
[Part1] Scraping with Python → Organize to csv!
How to enter Japanese with Python curses
[Python] How to deal with module errors
How to utilize Python with Jw_cad (Part 1 What is external transformation)
How to use Python with Jw_cad (Part 2 Command explanation and operation)
Upload images to Google Drive with Python
How to install python3 with docker centos
How to crop the lower right part of the image with Python OpenCV
How to start Python (Flask) when EC2 starts
How to read a CSV file with Python 2/3
How to enjoy programming with Minecraft (Ruby, Python)
[REAPER] How to play with Reascript in Python
How to do multi-core parallel processing with python
Strategy on how to monetize with Python Java
[Python] How to draw multiple graphs with Matplotlib
[Python] How to read excel file with pandas
How to specify attributes with Mock of python
How to use tkinter with python in pyenv
Upload files to Google Drive with Lambda (Python)
[Python] How to handle Japanese characters with openCV
[Python] How to compare datetime with timezone added
Flow to complete Slack authentication with Flask (Python)
How to install Python
How to install python
Programming with Python Flask
How to convert / restore a string with [] in python
How to add help to HDA (with Python script bonus)
[Python] How to draw a line graph with Matplotlib
How to scrape image data from flickr with python
How to do hash calculation with salt in Python
[Introduction to Python] How to iterate with the range function?
Explain in detail how to make sounds with python
How to run tests in bulk with Python unittest
How to make a shooting game with toio (Part 1)
How to measure mp3 file playback time with python
How to convert JSON file to CSV file with Python Pandas
[Python] How to deal with pandas read_html read error
How to get mouse wheel verdict with Python curses
[Python] How to rewrite the table style with python-pptx [python-pptx]
[Python] How to create a 2D histogram with Matplotlib
How to switch to smartphone mode with Python + Selenium + Chrome
How to operate Discord API with Python (bot registration)
[Python] How to draw a scatter plot with Matplotlib