Setting static folder path in Flask

It looks like my static files are not being served properly. Here's what it looks like now:

myApp
    __init__.py
    static
       img
       js
         bootstrap.min.js
       etc.

This is what my application configuration in mine __init__.pylooks like this:

app = Flask(__name__, static_url_path="", static_folder="static")

This is mistake:

127.0.0.1 - - [01/Dec/2014 13:12:01] "GET /static/js/bootstrap.min.js HTTP/1.1" 404 -

As for the routing URL does not go, no problems, LOCALHOST / home routes to the home, local / contact routes to contact, etc. But no static files were found :( Can I have something missing?

NOTE. I host this on my Mac, a purely localhost

This is my main method __init__.py:

if __name__ == "__main__":
    app.run(host='0.0.0.0', debug=True)

It is executed as:

python __init.py__
+4
source share
1 answer

, URL- . Flask URL - /static, , /static/js/bootstrap.min.js. , - .

<script src="/static/js/bootstrap.min.js"></script>

url_for URL- .

<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>

<script src="/js/bootstrap.min.js"></script>
+5

All Articles