Routing to a Service-Worker with Flask and PythonAnywhere

If you get a 404 error when you try to access from the browser, then it’s not your Flask route — it’s your static route. If you have a static file mapping with the “URL” set to /static then it will only pick up requests starting with

If you want to set up a static route specifically for the file sw.js and you want it to be accessible from, then you need to set up a static file mapping with a “URL” of /sw.js, and the “Directory” set to the full path to the file, for example /home/xxxxx/mysite/static/sw.js.

Check out the PythonAnywhere documentation for static files for more details.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top