Home > Software design >  Running multiple python files on heroku
Running multiple python files on heroku

Time:12-29

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

CodePudding user response:

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 scarpper.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.

PD: You only need one procfile containing the deployment information.

  • Related