2

My webapp has a little algo to swap images on mouseover. Behaves as expected on localhost, both when run at command line and when run as a container.

However, once deployed to Heroku, the algo fails -- it fails to correctly identify the name of the replacement image.

The naming convention is as follows, img-1, img-2, etc. and the algo locates the digit (using regex) and replaces with a randomly generated integer.

Again, it all works fine except on Heroku. Behavior suggests that the algo is failing in the regex area or in the random # generator.

These are the js functions used:

replace(/-[0-9]/,"-"+ Math.floor(Math.random() * 2))

The question, then, is there a reason why these functions would fail on Heroku?

I did run freeze requirements.txt before deploying, results as follows:

click==8.0.1
Flask==0.12
importlib-metadata==4.2.0
itsdangerous==2.0.1
Jinja2==3.0.1
joblib==1.0.1
MarkupSafe==2.0.1
nltk==3.6.2
regex==2021.4.4
tqdm==4.61.0
typing-extensions==3.10.0.0
Werkzeug==2.0.1
zipp==3.4.1
2

This has a speedy, happy ending. To wit:

Locally, this is the image url:

http://localhost:5001/static/img-0.jpg

while the cloud url is:

https://blah-0.herokuapp.com/static/img-0.jpg

...so the regex does indeed work, finding the first occurrence of "-0" which doesn't exist locally.

Easy fix by mod'ing the regex match condition to include ".jpg", no javascript problem, all is right in the world.

Would that all problems were so easily solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.