Skip to content

Instantly share code, notes, and snippets.

@bcse
Created August 28, 2015 06:59
Show Gist options
  • Select an option

  • Save bcse/18b3055a0e67c5cdf447 to your computer and use it in GitHub Desktop.

Select an option

Save bcse/18b3055a0e67c5cdf447 to your computer and use it in GitHub Desktop.

Revisions

  1. bcse created this gist Aug 28, 2015.
    8 changes: 8 additions & 0 deletions app.yaml
    Original 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
    34 changes: 34 additions & 0 deletions debrepo.py
    Original 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()