Forums

Setup Static Files in Flask

Reading from https://help.pythonanywhere.com/pages/DjangoStaticFiles , I do not understand how I can serve static files in Flask without putting an extra processing burden on the Python parts. Would this be sufficient?

  1. set up a static files mapping
  2. ensure all files in the static folder should be publicly accessible
  3. use normally url_for('static', filename='images/default_user_picture.jpeg')

Yes, that should be fine -- the extra step on PythonAnywhere is (1), i.e. setting static files mappings on the Web page. Everything else should be done according to the Flask docs.