Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: styleguide/c++/chromium-cpp/main.py

Issue 598063002: chromium-cpp: Set status code on errors, so that the console can track them. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 from google.appengine.api import memcache 6 from google.appengine.api import memcache
7 from google.appengine.api import urlfetch 7 from google.appengine.api import urlfetch
8 import webapp2 8 import webapp2
9 9
10 import base64 10 import base64
(...skipping 15 matching lines...) Expand all
26 def get(self, resource): 26 def get(self, resource):
27 if '..' in resource: # No path traversal. 27 if '..' in resource: # No path traversal.
28 self.response.write(':-(') 28 self.response.write(':-(')
29 return 29 return
30 30
31 url = BASE % resource 31 url = BASE % resource
32 contents = memcache.get(url) 32 contents = memcache.get(url)
33 if not contents or self.request.get('bust'): 33 if not contents or self.request.get('bust'):
34 result = urlfetch.fetch(url) 34 result = urlfetch.fetch(url)
35 if result.status_code != 200: 35 if result.status_code != 200:
36 self.response.set_status(result.status_code)
36 self.response.write('http error %d' % result.status_code) 37 self.response.write('http error %d' % result.status_code)
37 return 38 return
38 contents = base64.b64decode(result.content) 39 contents = base64.b64decode(result.content)
39 memcache.set(url, contents, time=5*60) # seconds 40 memcache.set(url, contents, time=5*60) # seconds
40 41
41 if resource.endswith('.css'): 42 if resource.endswith('.css'):
42 self.response.headers['Content-Type'] = 'text/css' 43 self.response.headers['Content-Type'] = 'text/css'
43 self.response.write(contents) 44 self.response.write(contents)
44 45
45 46
46 app = webapp2.WSGIApplication([ 47 app = webapp2.WSGIApplication([
47 ('/', MainHandler), 48 ('/', MainHandler),
48 ('/(\S+\.(?:css|html))', GitilesMirrorHandler), 49 ('/(\S+\.(?:css|html))', GitilesMirrorHandler),
49 ], debug=True) 50 ], debug=True)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698