Heroku is an app hosting company that offers a free tier. Heroku manages all of the hardware and administrative aspects of hosting a web app. All we need to do is instruct Heroku how to run the web app.
First, sign up for a free Heroku account and set up the Heroku CLI. Then, open a terminal and run the following commands (replacing example
as appropriate).
mkdir example
cd example
git init
heroku create example --buildpack heroku/python
The heroku/python
buildpack specifies that the app will require a Python runtime.
Create a new PROCFILE
to tell Heroku how to run your app.
web: python3 server.py
This instructs the Heroku web
server to execute python3 server.py
.
Commit the web app code to the Git repository.
git add .
git commit -m "Initial commit"
Then, push the commits to Heroku.
git push heroku master
If everything’s working properly, your web app is now accessible on the worldwide web!