How to serve files in flask to javascript like simplehttpserver does?

815 Views Asked by At

I'm working on a small web application based on Flask and I'd like to use gritter to flash messages, but I get the following error from JS: GET http: //127.0.0.1:5000/images/ie-spacer.gif 404 (NOT FOUND)

I have an images folder, but it doesn't work this way.. this url doesn't exist. I have a static folder, but the script tries to find these files in another folder.. in this case the images folder.

It seems I need some functionality like SimpleHTTPServer has. I also tried AutoIndex and static_url_path without success.

This is the reason I cannot use Flask for phaser.io as well. Am I missing something here?:(

1

There are 1 best solutions below

0
On

On a production system you'd ideally want use another web server to serve static files (like nginx or apache). It is possible to serve the files from flask directly though:

How to serve static files in Flask