This post is having some tips and notes about how to create a simple API.
It’s fun to code something useful right?
To install Heroku on your Ubuntu machine :
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.
After this you need to follow the following steps :
- create an app on heroku.
- git clone it.
- git add all your files.
- git commit.
- git push your files.
If you receive an 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.