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

Delta Between Two Patch Sets: sitescripts/cms/bin/test_server.py

Issue 5567002995326976: Multiple CMS improvements (Closed)
Left Patch Set: Created Dec. 11, 2013, 10:08 a.m.
Right Patch Set: Addressed comments Created Dec. 11, 2013, 12:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | sitescripts/cms/converters.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH 4 # Copyright (C) 2006-2013 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return None 44 return None
45 45
46 @app.route("/", methods = ["GET"]) 46 @app.route("/", methods = ["GET"])
47 @app.route("/<path:path>", methods = ["GET"]) 47 @app.route("/<path:path>", methods = ["GET"])
48 def show(path=""): 48 def show(path=""):
49 data = get_data(path) 49 data = get_data(path)
50 if data == None: 50 if data == None:
51 flask.abort(404) 51 flask.abort(404)
52 52
53 root, ext = os.path.splitext(path) 53 root, ext = os.path.splitext(path)
54 ext = ext.lower()
54 if ext == ".js": 55 if ext == ".js":
55 mime = "application/javascript; charset=utf-8" 56 mime = "application/javascript; charset=utf-8"
56 elif ext == ".css": 57 elif ext == ".css":
57 mime = "text/css; charset=utf-8" 58 mime = "text/css; charset=utf-8"
58 elif ext == ".png": 59 elif ext == ".png":
59 mime = "image/png" 60 mime = "image/png"
61 elif ext in (".jpg", ".jpeg"):
62 mime = "image/jpeg"
60 elif ext == "": 63 elif ext == "":
61 mime = "text/html; charset=utf-8" 64 mime = "text/html; charset=utf-8"
62 else: 65 else:
63 mime = "application/octet-stream" 66 mime = "application/octet-stream"
64 return data, 200, {"Content-Type": mime} 67 return data, 200, {"Content-Type": mime}
65 68
66 if __name__ == "__main__": 69 if __name__ == "__main__":
67 setupStderr() 70 setupStderr()
68 if len(sys.argv) < 2: 71 if len(sys.argv) < 2:
69 print >>sys.stderr, "Usage: %s source_dir" % sys.argv[0] 72 print >>sys.stderr, "Usage: %s source_dir" % sys.argv[0]
70 sys.exit(1) 73 sys.exit(1)
71 74
72 source = FileSource(sys.argv[1]) 75 source = FileSource(sys.argv[1])
73 76
74 # Make sure to "fix" argv to ensure that restart can succeed 77 # Make sure to "fix" argv to ensure that restart can succeed
75 sys.argv[0:1] = ["-m", "sitescripts.cms.bin.test_server"] 78 sys.argv[0:1] = ["-m", "sitescripts.cms.bin.test_server"]
76 79
77 app.run(debug=True) 80 app.run(debug=True)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld