Archive

Posts Tagged ‘images’

[flask] show external images with an app. running on localhost

November 3, 2019 Leave a comment

Problem
I have a Flask app. that I run on my local machine. I wrote it years ago and it worked well at that time. Now, I tried to run it again but the external images didn’t appear, they were broken. These are images that are located somewhere else, I just link them. When I copied their URL and pasted in the location bar of the browser, they appeared. What da?

Solution
It seems Firefox is blocking localhost, so when I visited http://127.0.0.1:5000, some of its elements got blocked.

As a workaround, I added the following line in my /etc/hosts file:

127.0.0.1   jabba-hq

Then, when I visted http://jabba-hq:5000, the images appeared normally.

Categories: flask, python Tags: ,
Design a site like this with WordPress.com
Get started