简体   繁体   中英

Python: Running Instapy on heroku

I am trying to create a instagram bot on heroku. I am new to this, I don't know where the tracebacks are going. heroku logs --tail Isn't much of a help.

What I did so far:

On the terminal:

heroku buildpacks:add heroku/chromedriver master

heroku buildpacks:add heroku/google-chrome master

Procfile:

web: gunicorn routes:app

routes.py:

from instapy import InstaPy
from instapy.util import smart_run
from flask import Flask


app = Flask(__name__)
# login credentials
insta_username = ''
insta_password = ''

# get an InstaPy session!
# set headless_browser=True to run InstaPy in the background
session = InstaPy(username=insta_username,
                password=insta_password,
                headless_browser=True,
                nogui=True)

@app.route('/')
def index():
    with smart_run(session):
        """ Activity flow """
        # settings
        session.set_relationship_bounds(
            enabled=True,
            delimit_by_numbers=True,
            max_followers=4590,
            min_followers=45,
            min_following=77)

        # actions
        session.like_by_tags(["natgeo"], amount=10)

    return 'Done'

I think you want to change your Procfile to this:

web: gunicorn app:app --log-file=-

for logging. Mine says app:app because my py file is called app, yours should say:

web: gunicorn routes:app --log-file=-

Also, I prefer to use the command:

heroku logs -t -a <insert app name here>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM