How to upolad python script to heroku and run it

Heroku is a cloud platform where you can host your website for free. Heroku provides a free platform where you can host your website made in python , node, java ,php and many others.

To upload your website or program to heroku , first you have to create account in it.

Pre Requisite:


To deploy your code to heroku

click on create new app.

heroku app












Enter a unique app name and then click on create app










Now your app willl be created 

Now you need to push your code to heroku

In cmd enter command
Suppose if your code is in  folder named "herokuApp" then from the parent folder of herokuApp in cmd type:
pipreqs herokuApp
It will create all the the requirements which are used in your python project.

Note
In some cases requirement file can be empty if your project doesn't contain any other downloaded module which do not come with the python package.

Before pushing code  download procfile in your "herokuApp" directory 

Open procfile and replace hello.py with the file name which your want to run when your app will be run

From cmd go to your folder in your system where your code is.

  • heroku login
  • git init
  • heroku git:remote -a hellopython1234(replace hellopython1234 with your app_name)
  • git add .
  • git commit -am "first heroku app"
  • git push heroku master

To run the python script on Heroku

In your "herokuApp" directory run command inside quotes:
"heroku run bash"
Now the heroku terminal will get started. To see all  the uploded file run command "ls".

To execute the python file run command
"python hello.py"

You can download the whole code from here

https://github.com/DeepakRawat001/herokuApp

Comments

Popular posts from this blog

How to make a folder completely hidden

Java

How to hack wifi password using cmd