[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]

I want to publish the app for free on Heroku!

It is a memo to review in such a case.

Register and install on Heroku

Register with your usual email address and password. Then install the Heroku CLI here [https://devcenter.heroku.com/articles/heroku-cli#download-and-install] If you download 64-bit Windows and run it, the installer will open, so install it as it is.

If you can do this, open the terminal

heroku login

And press the enter key Then, a window will open, so press the "LOGIN" button.

Once that's done heroku create <Application name> This time, I will make it as testappxxx01. * Please use a name that does not overlap with other people.

heroku create testappxxx01

Then connect remotely.

remote -a <Application name>


 Go to your working directory and

git init heroku git:remote -a testappxxx01


 Next, create the configuration files ``` runtime.txt``` and `` `requirements.txt```


#### **`runtime.txt`**
```text

python-3.7.3

requirements.txt


Flask==1.0.2

Once you've done this, write the source code.

main.py


from flask import Flask
import os

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, Heroku"

if __name__ == "__main__":
    port = int(os.getenv("PORT", 5000))
    app.run(host="0.0.0.0", port=port)

Then create a Procfile file to launch the app. When saving the file, do not add an extension, and save the Procfile and the leading P in uppercase.

Procfile


web: python main.py

If you can do this, it's one more step! !! The directory structure is

├── Working directory
    ├── main.py
    ├── runtime.txt
    ├── requirements.txt
   └── Procfile

All you have to do is type 4 magic commands.

git init
git add .
git commit -m "first commit"
git push heroku master

Confirm deployment

https://testappxxx01.herokuapp.com/


 In other words, you can check it at https: // app name.herokuapp.com/.
 Thank you for your hard work.


Recommended Posts

[Heroku] Memo for deploying Python apps using Heroku on Windows [Python]
Notes for using OpenCV on Windows10 Python 3.8.3.
Python environment construction memo on Windows 10
Python environment construction procedure memo using Docker on Windows10 Home
Python on Windows
[50 counts] Key transmission using Python for Windows
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
A memo of a tutorial on running python on heroku
(Windows) Causes and workarounds for UnicodeEncodeError on Python 3
Notes on installing Python3 and using pip on Windows7
A memorandum for touching python Flask on heroku
Notes for using TensorFlow on Bash on Ubuntu on Windows
Installing TensorFlow on Windows Easy for Python beginners
python basic on windows ②
Install python on windows
heroku memo (for myself)
Install Python (for Windows)
The key to deploying Flask apps using Python Buildpack on Cloud Foundry (Diego)
Initial settings for using Python3.8 and pip on CentOS8
Build a Python extension for E-Cell 4 on Windows 7 (64bit)
I tried python on heroku for the first time
A memo of installing Chainer 1.5 for GPU on Windows
Memo of deploying Django × Postgresql on Docker to Heroku
PIL with Python on Windows 8 (for Google App Engine)
Procedure for building a CDK environment on Windows (Python)
Minimum memo when using Python on Mac (pyenv edition)
Memo for building a machine learning environment using Python
For those who can't install Python on Windows XP
Set-enable Python virtualenv on Windows
Run Openpose on Python (Windows)
Python memo (for myself): Array
Install watchdog on Windows + Python 3.3
Python 3.6 installation procedure [for Windows]
Python + Kivy development on Windows
Try using OpenCV on Windows
F2py on Miniconda for Windows
Python code memo for yourself
Sphinx-autobuild (0.5.2) on Windows7, Python 3.5.1, Sphinx 1.3.5
Fastest Python installation on Windows
Build Python environment on Windows
Python memo using perl --join
Build python environment on windows
I ran python on windows
Broadcast on LINE using python
[Python] [Chainer] [Windows] Install Chainer on Windows
Use Python on Windows (PyCharm)
Install dlib for Python (Windows)
Build an environment for machine learning using Python on MacOSX
Access google spreadsheet using python on raspberry pi (for myself)
Build Python3 for Windows 10 on ARM with Visual Studio 2019 (x86) on Windows 10 on ARM
Memo of Linux environment construction using VirtualBox + Vagrant on Windows 10
Create a Python environment for professionals in VS Code on Windows
Python 3.6 on Windows ... and to Xamarin.
Installing Kivy on Windows10 64bit Python3.5
Anaconda python environment construction on Windows 10
What to do if Python doesn't work on Git for Windows
Install python2.7 on windows 32bit environment
Notes on using MeCab from Python
Install xgboost (python version) on Windows
Preparing python using vscode on ubuntu
Ansible playbook for setting up Python preferences using pyenv on Mac