I created a Horoscope API, using pyhoroscope package.
I used Flask and hosted it on Heroku. Heroku is free and price you, as you grow. It provides, for free 1 dyno. A dyno is an instance of your application running and responding to requests.
Installing Heroku tool belt
sudo apt-add-repository 'deb http://toolbelt.herokuapp.com/ubuntu ./' curl https://toolbelt.herokuapp.com/apt/release.key | sudo apt-key add - sudo apt-get update sudo apt-get install heroku-toolbelt sudo apt-get install ruby libopenssl-ruby ruby1.8-dev sudo apt-get install libreadline-ruby
This is how my python code looks like, which fetches and returns data from pyhoroscope package. For Python App Heroku needs a requirements.txt, so add it too. Add a Procfile too. Read more here.
You need to follow the following steps to create a git repository on Heroku as remote.
- Create an app on heroku.
- git clone it.
- git add all your files.
- git commit.
- git push your files.
If you receive error,
Try on the url after the completion if still not works check the error code, I got <strong>code=H14</strong> desc="No web processes running" method=GET path="/", using heroku logs
check the error code, here it’s H14, find how to solve it using this. For this particular error, you need to scale your dynos from 0 to 1.
#use this heroku ps:scale web=1
Read more about deploying your app from here.