0

I have hundreds of html files that I'm serving up in my flask website.

all the static files are referenced like this within these html pages:

<img src="lig60.png" id="app-logo">

How do make sure the .png files load even though they are in the static folder without making any changes to the html files?

The reason I don't want to make changes to the html files themselves is because there are hundreds and I don't want to be doing a find and replace which seems like not a very elegant solution.

Thanks in advance

1 Answer 1

2

It sounds like you are trying to have all of the files stored in static folder load from the site root. You could try this solution and see if it works:

https://vilimpoc.org/blog/2012/11/21/serving-static-files-from-root-and-not-static-using-flask/

app = Flask(__name__, static_url_path='')

This should set the default path of static files to the root URL. It will work if all your pages are loading in the root URL as well, but will not work if you have some subfolders there. To make it work from anywhere, you'd have to update all the links to at least have a '/' like this:

<img src="/lig60.png" id="app-logo">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.