Until you publish (deploy) a web application made with bottle on Heroku

Conclusion

Publish an application using bottle on Heroku.

Introduction

I made a web application with a Python bottle and tried to deploy it using Heroku, but it didn't work so I'll write an article as an output. Since this is my first post and I am a beginner, I would appreciate it if you could point out various things.

environment

Referenced site

-Making a web application (echolalia) using Heroku and python web framework bottle [for beginners] -Publish your web app in 4 minutes 33 seconds using Heroku x bottle

Basically, I think that there is no problem with the procedure of these sites, but I have a bug, so I hope you can refer to it at that time.

procedure

  1. Create a Heroku account
  2. Install the Heroku CLI
  3. Make a web app
  4. Create a directory to store the files you want to deploy (requires the following files)
    • main.py
    • requirement.txt
    • Procfile
    • runtime.txt
  1. Commit with git command
  2. Deploy to Heroku

Create a Heroku account

You can create an account here (https://signup.heroku.com/).

Install Heroku CLI

Install the Heroku CLI from here (https://devcenter.heroku.com/articles/heroku-cli). I was on Windows, so I ran heroku-x64.exe after downloading the installer. I left the defaults for everything I chose.

Creating a web app

Please make it. Note that it works in a remote environment. When running in a remote environment, I used the following code,

run(host="localhost",port=8080,debug=True)

When deploying, I changed it to the following code. I'm not sure what I'm doing around here, so I just copied the sutras for the time being.

run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))

Create a directory to store the files you want to deploy

There is nothing special about main.py and other files. ** Caution </ font> ** ** Pay attention to the character code of requirement.txt, Procfile, runtime.txt. I couldn't deploy with the character code utf-16 LE, but I could deploy with utf-8. ** **

requirement.txt This is a file that describes the module you want to import and its version. There seems to be a package when using numpy etc., but I stopped because I could not fix the error. The contents are as follows. The notation is module name == version.

requirement.txt


bottle==0.12.18
numpy==1.18.5
scikit-learn==0.23.1

Procfile I think this is a file that describes the python file to run (I don't understand much). I also created a file called Procfile.windows and wrote it as follows. Rename the main.py part below to your Python file. If you are using flask instead of bottle, it doesn't seem to be written as follows.

Procfile


web: python main.py

Procfile.windows


web: python main.py runserver 0.0.0.0:5000

runtime.txt This is the version of Python to run. It seems that the supported version of Heroku has been decided, so I chose Python-3.8.5 for the time being. It was different from my execution environment, but it was cool (probably not good). ** Please note that you will get an error if you make a mistake in case. ** **

runtime.txt


python-3.8.5

Attention (again)

** Pay attention to the character code of requirement.txt, Procfile, runtime.txt. I couldn't deploy with the character code utf-16 LE, but I could deploy with utf-8. ** **

Commit with git command

Navigate to the directory you want to deploy and commit that directory.

cd (Directory you want to deploy)
git init
git add --all
git commit -m "first commit"

Deploy to Heroku

It's finally time to deploy to Heroku. ~~ I took more time here than creating an app ~~

Login to Heroku

First, log in to Heroku. You will be asked for the email address and password you registered with Heroku, so enter them.

heroku login

If all goes well, you should see something like this:

Logged in as my email address

Deploy from app creation

Then do the following: This is creating an app on Heroku. If you do heroku create, it will tell you the address, but that address will be the address of the web application. In this case, the name is set appropriately, but it seems that you can set it yourself.

heroku create

Finally, push.

git push heroku master

If all goes well, you should see code similar to the following.

remote: Verifying deploy... done.

On the contrary, if it doesn't work, the following code will be displayed.

error: failed to push some refs to 'https://git.heroku.com/XXXXXXX.git'

At this time, if you look closely at the top of the error code, it will tell you where it got stuck, but it is not so kind. So, if you go to the https://git.heroku.com/XXXXXXX.git page, you can see the detailed log, so let's know more information there.

Check the app

If you can deploy

heroku open

You can check the app at.

Recommended Posts

Until you publish (deploy) a web application made with bottle on Heroku
(Failure) Deploy a web app made with Flask on heroku
# 1 Until you deploy Django's web application (instance construction with EC2 on AWS)
Publish a web application for viewing data created with Streamlit on heroku
How to deploy a web app made with Flask to Heroku
[Python] A quick web application with Bottle!
I made a WEB application with Django
Until you use PhantomJS with Python on Heroku
Until you publish a web service on GCP while studying JQuery and Python
Deploy a Django app made with PTVS on Azure
Deploy a web app created with Streamlit to Heroku
[No need to build local environment] Deploy Python bottle application made with Cloud9 to Heroku
Deploy a Django application on EC2 with Nginx + Gunicorn + Supervisor
Deploy a Django application with Docker
Build a web application with Django
If you know Python, you can make a web application with Django
Build a Flask / Bottle-like web application on AWS Lambda with Chalice
How to deploy a web application on Alibaba Cloud as a freelancer
Launched a web application on AWS with django and changed jobs
Run a Python web application with Docker
Launch Flask application with Docker on Heroku
Until you publish your Django application (+ MySQL) on AWS EC2 (+ RDS (+ S3))
Until you CI what you made with Django with Jenkins
[Raspberry Pi] Publish a web application on https using Apache + WSGI + Python Flask
I made a GUI application with Python + PyQt5
Until you install Python with pythonbrew and run Flask on a WSGI server
Until you run a Flask application on Google App Engine for the time being
I made a web application that maps IT event information with Vue and Flask
Until you create a machine learning environment with Python on Windows 7 and run it
Deploy a Python 3.6 / Django / Postgres web app on Azure
Until the web application is released on Sakura VPS
Looking back on creating a web service with Django 1
Deploy a Django application on Google App Engine (Python3)
I made a Python3 environment on Ubuntu with direnv.
Launch a Python web application with Nginx + Gunicorn with Docker
Looking back on creating a web service with Django 2
I made a LINE BOT with Python and Heroku
Web application made with Python3.4 + Django (Part.1 Environment construction)
[GitHub] Until you pull with ssh using Deploy keys
Deploy a real-time web app with swampdragon x apache
Web application using Bottle (1)
Create a web application that recognizes numbers with a neural network
I made a simple book application with python + Flask ~ Introduction ~
Star Wars release commemoration, Star Wars style TL application made with bottle
Web application with Python3.3.1 + Bottle (1) --Change template engine to jinja2
I made you to execute a command from a web browser
Create a Python3.4 + Nginx + uWSGI + Flask Web application execution environment with haste using pyenv on Ubuntu 12.04
Web application development with Flask
Deploy masonite app on Heroku 2020
Web application creation with Django
Web application with Python + Flask ② ③
Web application with Python + Flask ④
A note on what you did to use Flycheck with Python
Let's make a WEB application for phone book with flask Part 1
I made a web server with Raspberry Pi to watch anime
Publish your web app in 4 minutes 33 seconds using Heroku x bottle
Let's make a WEB application for phone book with flask Part 2
How to deploy a Django app on heroku in just 5 minutes
I tried to make a todo application using bottle with python
I made a scaffolding tool for the Python web framework Bottle
Let's make a WEB application for phone book with flask Part 4