Skip to content

Commit

Permalink
missing static files now properly send 404 instead of 500
Browse files Browse the repository at this point in the history
  • Loading branch information
glennyonemitsu committed Apr 17, 2013
1 parent 2ea6008 commit 1563eec
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sdklib/wsgi.py
Expand Up @@ -9,7 +9,7 @@
import os.path
import sys

from flask import Flask, make_response, request, send_from_directory
from flask import Flask, abort, make_response, request, send_from_directory
from jinja2 import Environment, FileSystemLoader
from markdown import markdown
import scss
Expand Down Expand Up @@ -122,38 +122,38 @@ def _dispatch_rule(self, **kwargs):
return template.render(**kwargs)

def _dispatch_static(self, filename):
static_file = os.path.join(self.static_path, filename)
if not os.path.isfile(static_file):
return abort(404)

# scss support
if filename.startswith('css/') and filename.endswith('.scss'):
scss_file = os.path.join(self.static_path, filename)
_scss = scss.Scss()
css = _scss.compile(scss_file=scss_file)
css = _scss.compile(scss_file=static_file)
res = make_response()
res.data = css
res.mimetype = 'text/css'
return res

# stylus support
elif filename.startswith('css/') and filename.endswith('.styl'):
stylus_file = os.path.join(self.static_path, filename)
css = compile_stylus(stylus_file)
css = compile_stylus(static_file)
res = make_response()
res.data = css
res.mimetype = 'text/css'
return res

# less support
elif filename.startswith('css/') and filename.endswith('.less'):
less_file = os.path.join(self.static_path, filename)
css = compile_less(less_file)
css = compile_less(static_file)
res = make_response()
res.data = css
res.mimetype = 'text/css'
return res

# coffeescript support
elif filename.startswith('js/') and filename.endswith('.coffee'):
cs_file = os.path.join(self.static_path, filename)
cs_data = compile_coffeescript(cs_file)
cs_data = compile_coffeescript(static_file)
res = make_response()
res.data = cs_data
res.mimetype = 'application/javascript'
Expand Down

0 comments on commit 1563eec

Please sign in to comment.