Skip to content

Instantly share code, notes, and snippets.

@bcse
Created August 28, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcse/18b3055a0e67c5cdf447 to your computer and use it in GitHub Desktop.
Save bcse/18b3055a0e67c5cdf447 to your computer and use it in GitHub Desktop.
Debian repository on Google App Engine
application: altcanvas-repo
version: 1
runtime: python
api_version: 1
handlers:
- url: .*
script: debrepo.py
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment