Running multiple python files on heroku

Question:

I have 3 files:

  1. webapp.py => simple flask app that with every GET requests reads stock.txt and shows it content

  2. scrapper.py => simple bs4 scrapper that scraps a site every 5 minutes and saves its stock to a file stock.txt

  3. stock.txt => stores the stock from scrapper.ppy

I have no problem running it on my local pc but i dont know how to deploy it to heroku

I cant find an simple answer on heroku docs

Asked By: laxmymow

||

Answers:

Well you’ll find a lot of problems if you are not familiar with Heroku in the first place.

In Heroku you have to build your Procfile and with this configure your webapp, clock and jobs.

Example Procfile for a web application:

web: gunicorn webapp:app 

Example Procfile for a clock (scheduled job):

clock: python scrapper.py

And with the last one you have some serious problem because Heroku have a virtual instance of you code so modifications to your repository files will not be persisted. Maybe think of using a Database.

PS: You only need one Procfile containing the deployment information.