I have a plan, homewith a prefix /in my Flask application. The plan has a static folder and is configured with an argument static_folder. However, binding to static drawing files returns a 404 error, although the file exists and the URL looks correct. Why the project does not put static files?
myproject/
run.py
myapp/
__init__.py
home/
__init__.py
templates/
index.html
static/
css/
style.css
myapp/init.py:
from flask import Flask
application = Flask(__name__)
from myproject.home.controllers import home
application.register_blueprint(home, url_prefix='/')
myapp/home/controllers.py:
from flask import Blueprint, render_template
home = Blueprint('home', __name__, template_folder='templates', static_folder='static')
@home.route('/')
def index():
return render_template('index.html')
myapp/home/templates/index.html:
<head>
<link rel="stylesheet" href="{{url_for('home.static', filename='css/style.css')}}">
</head>
<body>
</body>
myapp/home/static/css/style.css:
body {
background-color: green;
}
source
share