Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/cms/bin/test_server.py

Issue 5567002995326976: Multiple CMS improvements (Closed)
Patch Set: Addressed comments Created Dec. 11, 2013, 12:02 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sitescripts/cms/converters.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | sitescripts/cms/converters.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld