(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
Create two files required for deployment.
First, create requirements.txt as a file that tells you what libraries you need to run your app on Heroku. Enter the following in my-projet.
pip freeze > requirements.txt
In requirements.txt, a file showing the list of installed libraries is created.
Next, create a Procfile as a file that describes the command that will be executed first when you start the app on Heroku (no extension specified).
touch Profile
Open the created Procfile, enter the following and save it.
web: gunicorn hello:app --log-file -
It means to open a server called app in hello.py. If you don't add a space behind the web, you will get an error when you deploy to Heroku later, so be careful.
First, enter the following in the terminal to show the current state of the files in my-project.
git status
Then specify which files to deploy to Heroku. Specify all files and enter the following.
git add .
Then type the following and check the status again to see if the file is ready to deploy.
git status
Next, these files need to state the need to explain what has been updated and what has changed. This time, enter the following as'the-first'.
git commit -m'the-first'
If you check the status again,
git status
It is displayed that all files are ready to be deployed (committed).
On branch master
nothing to commit, working tree clean
Now you're ready to push (deploy) your files to Heroku. Enter the following and push (deploy) to Heroku.
git push heroku master
Finally, enter the following to confirm the deployment.
heroku open
Success if the browser opens and the following is displayed.
[How to upload with Heroku, Flask, Python, Git (4)] (https://qiita.com/drafts/0352898c40830547015f/edit?resume=true)
Recommended Posts