Index: sitescripts/cms/bin/test_server.py |
=================================================================== |
--- a/sitescripts/cms/bin/test_server.py |
+++ b/sitescripts/cms/bin/test_server.py |
@@ -16,17 +16,17 @@ |
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
import sys, os, flask |
from ...utils import setupStderr |
from ..utils import process_page |
from ..sources import FileSource |
from ..converters import converters |
-app = flask.Flask("sitescripts.web.bin.test_server") |
+app = flask.Flask("sitescripts.cms.bin.test_server") |
source = None |
def get_data(path): |
if source.has_static(path): |
return source.read_static(path) |
path = path.rstrip("/") |
if path == "": |
@@ -46,32 +46,35 @@ def get_data(path): |
@app.route("/", methods = ["GET"]) |
@app.route("/<path:path>", methods = ["GET"]) |
def show(path=""): |
data = get_data(path) |
if data == None: |
flask.abort(404) |
root, ext = os.path.splitext(path) |
+ ext = ext.lower() |
if ext == ".js": |
mime = "application/javascript; charset=utf-8" |
elif ext == ".css": |
mime = "text/css; charset=utf-8" |
elif ext == ".png": |
mime = "image/png" |
+ elif ext in (".jpg", ".jpeg"): |
+ mime = "image/jpeg" |
elif ext == "": |
mime = "text/html; charset=utf-8" |
else: |
mime = "application/octet-stream" |
return data, 200, {"Content-Type": mime} |
if __name__ == "__main__": |
setupStderr() |
if len(sys.argv) < 2: |
print >>sys.stderr, "Usage: %s source_dir" % sys.argv[0] |
sys.exit(1) |
source = FileSource(sys.argv[1]) |
# Make sure to "fix" argv to ensure that restart can succeed |
- sys.argv[0:1] = ["-m", "sitescripts.web.bin.test_server"] |
+ sys.argv[0:1] = ["-m", "sitescripts.cms.bin.test_server"] |
app.run(debug=True) |