Skip to content

Commit 7bd948d

Browse files
committed
Add content-type to css files
1 parent 2805a7b commit 7bd948d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

server.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! env python
2-
from flask import Flask, Response, request, jsonify
2+
from flask import Flask, Response, jsonify, make_response, request
33
from mimetypes import guess_type
44
from os.path import isfile
55
import sys
@@ -109,9 +109,18 @@ def catch_all(path):
109109
# Run SASS/SCSS/LESS files through the appropriate compiler
110110
if path.endswith('.scss') or path.endswith('.sass'):
111111
content = str(Helpers.returncontent(path), 'utf-8')
112-
return sass.compile(string=content, output_style='compressed')
112+
css = sass.compile(string=content, output_style='compressed')
113+
r = make_response(css)
114+
r.headers['Content-Type'] = 'text/css'
115+
r.headers['X-Content-Type-Options'] = 'nosniff'
116+
return r
117+
113118
if path.endswith('.less'):
114-
return lesscpy.compile(path, minify=True)
119+
css = lesscpy.compile(path, minify=True)
120+
r = make_response(css)
121+
r.headers['Content-Type'] = 'text/css'
122+
r.headers['X-Content-Type-Options'] = 'nosniff'
123+
return r
115124

116125
# For everything else, just send it
117126
content = Helpers.returncontent(path)

0 commit comments

Comments
 (0)