Heroku building a simple python application.

Heroku building a simple python application.
Heroku is a platfom as a service where we can build and deploy our applications, with platform as a sevice there is no need to worry about the dependencies hassles to setup environmens fot developers.

I am creating a simple python on heroku to test it.
let in install the pipenv , pipenv can be used to create python applications.

$pip install pipenv --user 
Collecting pipenv
  Using cached pipenv-11.9.0.tar.gz
Requirement already satisfied: pip>=9.0.1 in /usr/lib/python2.7/site-packages (from pipenv)
Collecting certifi (from pipenv)
  Using cached certifi-2018.1.18-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=36.2.1 in /usr/lib/python2.7/site-packages (from pipenv)
Collecting virtualenv-clone>=0.2.5 (from pipenv)
  Using cached virtualenv_clone-0.3.0-py2.py3-none-any.whl
Collecting virtualenv (from pipenv)
  Using cached virtualenv-15.2.0-py2.py3-none-any.whl
Requirement already satisfied: requests[security] in /usr/lib/python2.7/site-packages (from pipenv)
Collecting ordereddict (from pipenv)
  Using cached ordereddict-1.1.tar.gz
Collecting pathlib (from pipenv)
  Using cached pathlib-1.0.1.tar.gz
Requirement already satisfied: urllib3==1.20 in /usr/lib/python2.7/site-packages (from requests[security]->pipenv)
Requirement already satisfied: pyOpenSSL>=0.14 in /usr/lib/python2.7/site-packages (from requests[security]->pipenv)
Requirement already satisfied: cryptography>=1.3.4 in /usr/lib64/python2.7/site-packages (from requests[security]->pipenv)
Requirement already satisfied: idna>=2.0.0 in /usr/lib/python2.7/site-packages (from requests[security]->pipenv)
Requirement already satisfied: six>=1.5.2 in /usr/lib/python2.7/site-packages (from pyOpenSSL>=0.14->requests[security]->pipenv)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/lib/python2.7/site-packages (from cryptography>=1.3.4->requests[security]->pipenv)
Requirement already satisfied: enum34 in /usr/lib/python2.7/site-packages (from cryptography>=1.3.4->requests[security]->pipenv)
Requirement already satisfied: ipaddress in /usr/lib/python2.7/site-packages (from cryptography>=1.3.4->requests[security]->pipenv)
Requirement already satisfied: cffi>=1.7 in /usr/lib64/python2.7/site-packages (from cryptography>=1.3.4->requests[security]->pipenv)
Requirement already satisfied: pycparser in /usr/lib/python2.7/site-packages (from cffi>=1.7->cryptography>=1.3.4->requests[security]->pipenv)
Installing collected packages: certifi, virtualenv-clone, virtualenv, ordereddict, pathlib, pipenv
  Running setup.py install for ordereddict ... done
  Running setup.py install for pathlib ... done
  Running setup.py install for pipenv ... done
Successfully installed certifi-2018.1.18 ordereddict-1.1 pathlib-1.0.1 pipenv-11.9.0 virtualenv-15.2.0 virtualenv-clone-0.3.0

Downloading Heroku tool from wget and installation.

 cipher  ~  wget https://cli-assets.heroku.com/branches/stable/heroku-linux-amd64.tar.gz 
--2018-04-03 16:38:52--  https://cli-assets.heroku.com/branches/stable/heroku-linux-amd64.tar.gz
Resolving cli-assets.heroku.com (cli-assets.heroku.com)... 54.230.190.237, 54.230.190.23, 54.230.190.127, ...
Connecting to cli-assets.heroku.com (cli-assets.heroku.com)|54.230.190.237|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21425775 (20M) [application/x-tar]
Saving to: ‘heroku-linux-amd64.tar.gz’

heroku-linux-amd64.tar.gz                    100%[===========================================================================================>]  20.43M   229KB/s    in 72s     

2018-04-03 16:40:05 (292 KB/s) - ‘heroku-linux-amd64.tar.gz’ saved [21425775/21425775]

 cipher  ~  sudo mkdir -p /usr/local/lib /usr/local/bin 
 cipher  ~  sudo tar -xvzf  heroku-linux-amd64.tar.gz -C /usr/local/lib


 cipher  ~  sudo ln -s /usr/local/lib/heroku/bin/heroku /usr/local/bin/heroku

Logging into heroku account from cli.

cipher  ~  heroku login 
Enter your Heroku credentials:
Email: pawaan.v[at]gmail.com
Password: ***********
Logged in as pawaan.v[at]gmail.com

A new python application can be built of a git repo can be cloned and heroku can help to build the python application, i am using a python-getting-started git repository to colne and deploying the app using heroku.

 cipher  ~  git clone https://github.com/heroku/python-getting-started.git 
Cloning into 'python-getting-started'...
remote: Counting objects: 385, done.
remote: Total 385 (delta 0), reused 0 (delta 0), pack-reused 385
Receiving objects: 100% (385/385), 66.22 KiB | 111.00 KiB/s, done.
Resolving deltas: 100% (191/191), done.
 cipher  ~  cd python-getting-started/

Lets deploy the app with heroku create.

 cipher  ~  python-getting-started  heroku create 
Creating app... done, ⬢ floating-brushlands-50838
https://floating-brushlands-50838.herokuapp.com/ | https://git.heroku.com/floating-brushlands-50838.git

This creates an app, a git remote called heroku is also created and associated with your local git repository
Heroku creates a random name for the application or we can specify application name.

After the application coding is done it can be deployed to git , with git push

Counting objects: 385, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (170/170), done.
Writing objects: 100% (385/385), 66.22 KiB | 66.22 MiB/s, done.
Total 385 (delta 191), reused 385 (delta 191)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing python-3.6.4
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote:        Installing dependencies from Pipfile.lock (2899d6)…
remote: -----> $ python manage.py collectstatic --noinput
remote:        119 static files copied to '/tmp/build_22daab7c1e460e60043d49727b591682/staticfiles', 145 post-processed.
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 62.8M
remote: -----> Launching...
remote:        Released v4
remote:        https://floating-brushlands-50838.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/floating-brushlands-50838.git
 * [new branch]      master -> master

The app is now deployed can be accessed from https://floating-brushlands-50838.herokuapp.com/ or we can ue command heroku open from the comamnd line to open the app location.

a minimum of one app instance is required to run,

 cipher  ~  python-getting-started  heroku ps:scale web=1
Scaling dynos... done, now running web at 1:Free

Checking heroku logs.

 cipher  ~  python-getting-started  heroku logs --tail 
2018-04-03T11:21:40.495436+00:00 app[api]: Initial release by user pawaan.v@gmail.com
2018-04-03T11:21:40.495436+00:00 app[api]: Release v1 created by user pawaan.v@gmail.com
2018-04-03T11:21:40.628925+00:00 app[api]: Enable Logplex by user pawaan.v@gmail.com
2018-04-03T11:21:40.628925+00:00 app[api]: Release v2 created by user pawaan.v@gmail.com
2018-04-03T11:27:01.000000+00:00 app[api]: Build started by user pawaan.v@gmail.com
2018-04-03T11:27:42.996773+00:00 app[api]: Attach DATABASE (@ref:postgresql-rectangular-47218) by user pawaan.v@gmail.com
2018-04-03T11:27:42.996773+00:00 app[api]: Release v3 created by user pawaan.v@gmail.com
2018-04-03T11:27:43.279136+00:00 app[api]: Release v4 created by user pawaan.v@gmail.com
2018-04-03T11:27:43.299685+00:00 app[api]: Scaled to web@1:Free by user pawaan.v@gmail.com
2018-04-03T11:27:43.279136+00:00 app[api]: Deploy f56b9049 by user pawaan.v@gmail.com
2018-04-03T11:27:01.000000+00:00 app[api]: Build succeeded
2018-04-03T11:27:48.093079+00:00 heroku[web.1]: Starting process with command `gunicorn gettingstarted.wsgi`
2018-04-03T11:27:51.329927+00:00 app[web.1]: [2018-04-03 11:27:51 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-04-03T11:27:51.330401+00:00 app[web.1]: [2018-04-03 11:27:51 +0000] [4] [INFO] Listening at: https://0.0.0.0:47375 (4)
2018-04-03T11:27:51.330500+00:00 app[web.1]: [2018-04-03 11:27:51 +0000] [4] [INFO] Using worker: sync
2018-04-03T11:27:51.333901+00:00 app[web.1]: [2018-04-03 11:27:51 +0000] [8] [INFO] Booting worker with pid: 8
2018-04-03T11:27:51.359669+00:00 app[web.1]: [2018-04-03 11:27:51 +0000] [9] [INFO] Booting worker with pid: 9
2018-04-03T11:27:52.343330+00:00 heroku[web.1]: State changed from starting to up
2018-04-03T11:29:01.166954+00:00 heroku[router]: at=info method=GET path="/" host=floating-brushlands-50838.herokuapp.com request_id=0253b398-b83d-432d-be0c-4cfe40263ac4 fwd="223.237.254.60" dyno=web.1 connect=0ms service=30ms status=200 bytes=7616 protocol=https
2018-04-03T11:29:01.166640+00:00 app[web.1]: 10.45.100.228 - - [03/Apr/2018:11:29:01 +0000] "GET / HTTP/1.1" 200 7425 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
2018-04-03T11:29:01.684725+00:00 heroku[router]: at=info method=GET path="/static/lang-logo.png" host=floating-brushlands-50838.herokuapp.com request_id=927dacdb-342a-4a1c-9b47-39779b2310b6 fwd="223.237.254.60" dyno=web.1 connect=0ms service=3ms status=200 bytes=2476 protocol=https
2018-04-03T11:29:01.684098+00:00 app[web.1]: 10.33.239.90 - - [03/Apr/2018:11:29:01 +0000] "GET /static/lang-logo.png HTTP/1.1" 200 - "https://floating-brushlands-50838.herokuapp.com/" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
2018-04-03T11:29:04.323962+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=floating-brushlands-50838.herokuapp.com request_id=680e3452-0139-4076-9fa8-ddb4958fc2af fwd="223.237.254.60" dyno=web.1 connect=1ms service=11ms status=404 bytes=2419 protocol=https
2018-04-03T11:29:04.336636+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=floating-brushlands-50838.herokuapp.com request_id=82b7b622-9a2c-48ba-9386-2bd733c2615b fwd="223.237.254.60" dyno=web.1 connect=1ms service=5ms status=404 bytes=2419 protocol=https
2018-04-03T11:29:04.322891+00:00 app[web.1]: Not Found: /favicon.ico
2018-04-03T11:29:04.323315+00:00 app[web.1]: 10.33.239.90 - - [03/Apr/2018:11:29:04 +0000] "GET /favicon.ico HTTP/1.1" 404 2236 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
2018-04-03T11:29:04.335423+00:00 app[web.1]: Not Found: /favicon.ico
2018-04-03T11:29:04.335808+00:00 app[web.1]: 10.45.100.228 - - [03/Apr/2018:11:29:04 +0000] "GET /favicon.ico HTTP/1.1" 404 2236 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
2018-04-03T11:31:04.721715+00:00 heroku[router]: at=info method=GET path="/" host=floating-brushlands-50838.herokuapp.com request_id=5e58e67e-0ea7-40df-a9cd-dd3a67fbcd4a fwd="223.237.254.60" dyno=web.1 connect=1ms service=3ms status=200 bytes=7616 protocol=https
2018-04-03T11:31:04.720546+00:00 app[web.1]: 10.151.49.221 - - [03/Apr/2018:11:31:04 +0000] "GET / HTTP/1.1" 200 7425 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
2018-04-03T11:31:05.209536+00:00 heroku[router]: at=info method=GET path="/static/lang-logo.png" host=floating-brushlands-50838.herokuapp.com request_id=46e6b49e-cc8e-4408-a8e0-892d8e7ab2c0 fwd="223.237.254.60" dyno=web.1 connect=1ms service=3ms status=304 bytes=144 protocol=https
2018-04-03T11:31:05.209148+00:00 app[web.1]: 10.5.228.216 - - [03/Apr/2018:11:31:05 +0000] "GET /static/lang-logo.png HTTP/1.1" 304 - "https://floating-brushlands-50838.herokuapp.com/" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"