I am not able to load the style.css for the index with flask, I have tried everything, but it does not correctly read the file style.css.
The structure goes as follows:
my_folder/app.py
my_folder/templates/index.html
my_folder/static/css/style.css
my_folder/static/scss/style.scss
my_folder/static/img/logo.png
Code from the file index.html:
<head>
<meta charset="UTF-8">
<title>Responsive Table</title>
<script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="static/css/style.css">
</head>
Code from app.py:
import numpy as np
from flask import Flask, request, render_template
import pickle
import pandas as pd
import os
app = Flask(__name__)
model_logreg = pickle.load(open('Models/logreg.pkl', 'rb'))
PICTURE_FOLDER = os.path.join('static', 'img')
app.config['UPLOAD_FOLDER'] = PICTURE_FOLDER
full_filename = os.path.join(app.config['UPLOAD_FOLDER'], 'logo.png')
@app.route('/')
def home():
return render_template('index.html', value1 = 1, value2 = 1, value3 = 1, value4 = 1, value5 = 1, value6 = 1, user_image = full_filename)
@app.route('/predict',methods=['POST'])
def predict():
int_features = [str(x) for x in request.form.values()]
final_features = np.array(int_features)
... bla bla bla ...
if __name__ == "__main__":
app.run(host='0.0.0.0',port=8080)
Extra info: the file style.css is completely right because I copy-pasted the code in index.html and works fine. So it is just a path-finding problem.
Thanks everyone.