Created
August 28, 2015 06:59
-
-
Save bcse/18b3055a0e67c5cdf447 to your computer and use it in GitHub Desktop.
Revisions
-
bcse created this gist
Aug 28, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ application: altcanvas-repo version: 1 runtime: python api_version: 1 handlers: - url: .* script: debrepo.py This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ from google.appengine.ext import webapp import google.appengine.api.urlfetch as urlfetch from google.appengine.ext.webapp.util import run_wsgi_app import logging code_url = 'http://altcanvas.googlecode.com/files/' repo_path = '/dists/testing/main/binary-armel/' tmp_path = '/binary-armel/' mime_map = { 'deb':'application/x-debian-package', 'gz':'application/x-gzip' } class FilePipe(webapp.RequestHandler): def get(self,filename): fetch_headers = {'Cache-Control':'no-cache,max-age=0', 'Pragma':'no-cache'} f = urlfetch.fetch(code_url+filename,method=urlfetch.GET,headers=fetch_headers) fileext = filename.split('.')[-1] self.response.headers['Content-Type'] = mime_map[fileext] self.response.headers['Content-Length'] = '%d'%(len(f.content)) self.response.out.write(f.content) application = webapp.WSGIApplication( [(repo_path+'(.*)', FilePipe), (tmp_path+'(.*)', FilePipe)], debug=True) def main(): run_wsgi_app(application) if __name__ == "__main__": main()