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

Side by Side Diff: gae/pre_cacher.py

Issue 933813004: [chrome-devtools-frontend] Updated example links for local debugging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chrome-devtools-frontend
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« 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 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from google.appengine.api import urlfetch 5 from google.appengine.api import urlfetch
6 import webapp2 6 import webapp2
7 7
8 import cache 8 import cache
9 import config 9 import config
10 10
11 class PreCacherFromUrl(webapp2.RequestHandler): 11 class PreCacherFromUrl(webapp2.RequestHandler):
12 # 12 #
13 # For local testing (since /gs paths are not available), precache the 13 # For local testing (since /gs paths are not available), precache the
14 # meta-file (e.g. for revision 155046): 14 # meta-file (e.g. for revision 155046) from your browser:
15 # 15 #
16 # http://localhost:8080/precache_url?path=revs/@155046&url=http://commondatast orage.googleapis.com/chrome-devtools-frontend/revs/@155046 16 # http://localhost:8080/precache_url?path=revs/@155046&url=http://commondatast orage.googleapis.com/chrome-devtools-frontend/revs/@155046
17 # 17 #
18 # Then pre-cache the archive (you need to look up MD5 from the meta-file): 18 # Then pre-cache the archive (you need to look up MD5 from the meta-file from the 'revs' metafile):
19 # 19 #
20 # http://localhost:8080/precache_url?path=zips/47c84e4ba2eb60f9f476203f332fe58 43c194c63.zip&url=http://commondatastorage.googleapis.com/chrome-devtools-fronte nd/zips/47c84e4ba2eb60f9f476203f332fe5843c194c63.zip 20 # http://localhost:8080/precache_url?path=zips/e4eb112917d276dac7b43affa304221 43f37fd26.zip&url=http://commondatastorage.googleapis.com/chrome-devtools-fronte nd/zips/e4eb112917d276dac7b43affa30422143f37fd26.zip
21 # 21 #
22 # Then this works: http://localhost:8080/serve_rev/@155046/devtools.html 22 # Then this works: http://localhost:8080/serve_rev/@155046/devtools.html
23 # 23 #
24 # Remember to re-populate the cache after the server restarts (e.g. after 24 # Remember to re-populate the cache after the server restarts (e.g. after
25 # changing source files). 25 # changing source files).
26 # 26 #
27 def get(self): 27 def get(self):
28 if config.IS_DEV_APP_SERVER: 28 if config.IS_DEV_APP_SERVER:
29 path = self.request.GET['path'] 29 path = self.request.GET['path']
30 url = self.request.GET['url'] 30 url = self.request.GET['url']
31 self.response.headers['Content-Type'] = 'text/plain' 31 self.response.headers['Content-Type'] = 'text/plain'
32 self.response.write(precache_url(path, url)) 32 self.response.write(precache_url(path, url))
33 else: 33 else:
34 self.abort(403) 34 self.abort(403)
35 35
36 def precache_url(file_name, url): 36 def precache_url(file_name, url):
37 result = urlfetch.fetch(url) 37 result = urlfetch.fetch(url)
38 if result.status_code == 200: 38 if result.status_code == 200:
39 cache.set_content(file_name, result.content) 39 cache.set_content(file_name, result.content)
40 return 'Cached %s as %s' % (url, file_name) 40 return 'Cached %s as %s' % (url, file_name)
41 else: 41 else:
42 return 'Error: %d for %s' % (result.status_code, url) 42 return 'Error: %d for %s' % (result.status_code, url)
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