rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 1 | # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import autoupdate |
| 6 | import buildutil |
| 7 | import os |
| 8 | import web |
chocobo@google.com | 4dc2581 | 2009-10-27 23:46:26 +0000 | [diff] [blame^] | 9 | import sys |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 10 | |
| 11 | urls = ('/', 'index', |
| 12 | '/update', 'update') |
| 13 | |
| 14 | app = web.application(urls, globals()) |
| 15 | render = web.template.render('templates/') |
| 16 | |
| 17 | |
| 18 | class index: |
| 19 | def GET(self): |
| 20 | pkgs = buildutil.GetPackages() |
| 21 | return render.index(pkgs) |
| 22 | |
| 23 | class update: |
| 24 | """ |
| 25 | Processes updates from the client machine. If an update is found, the url |
| 26 | references a static link that can be served automagically from web.py. |
| 27 | """ |
| 28 | def POST(self): |
| 29 | return autoupdate.HandleUpdatePing(web.data()) |
| 30 | |
chocobo@google.com | 4dc2581 | 2009-10-27 23:46:26 +0000 | [diff] [blame^] | 31 | if __name__ == "__main__": |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 32 | web.debug("Setting up the static repo") |
chocobo@google.com | 4dc2581 | 2009-10-27 23:46:26 +0000 | [diff] [blame^] | 33 | static_dir = os.path.realpath("%s/static" % os.path.dirname(sys.argv[0])) |
| 34 | web.debug("Serving images from %s" % static_dir) |
rtc@google.com | ded2240 | 2009-10-26 22:36:21 +0000 | [diff] [blame] | 35 | os.system("mkdir -p %s" % static_dir) |
| 36 | app.run() |
| 37 | |