Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask static files getting 404

I am building a basic web app with following project structure. The app is fine but I am getting 404 errors for some of the static files.

I don't have any file like this bootstrap.css.map and not able to find enough docs related to this in flask.

127.0.0.1 - - [09/Feb/2014 22:37:17] "GET /static/css/bootstrap.css.map HTTP/1.1" 404 -

@app.route('/')
def index():
print 'in /'
return send_file('templates/login.html')

Directory structure:

app/
├── static/
│   └── bootstrap.min.css
├── templates/
│   └── index.html
└── app.py

EDIT: Here is my login html

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<title>API Test Application</title>

<!-- Bootstrap core CSS -->
<link href="/static/css/bootstrap.min.css" rel="stylesheet">

<!-- Custom CSS for the 'Thumbnail Gallery' Template -->
<link href="/static/css/2-col-portfolio.css" rel="stylesheet">
</head>

<body>
 ......simple login form..........
</body>
</html>
like image 945
San Avatar asked Feb 10 '14 03:02

San


1 Answers

Set _static_folder location against Flask.

app = Flask(__name__)
app._static_folder = <path to to your static directory>
like image 96
Bitmap Avatar answered Oct 15 '22 14:10

Bitmap