blob: 9e2e9cd7f05db8754295c3a23a6885ae65b4be23 [file] [log] [blame]
rtc@google.comded22402009-10-26 22:36:21 +00001# 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
5import autoupdate
6import buildutil
7import os
8import web
chocobo@google.com4dc25812009-10-27 23:46:26 +00009import sys
rtc@google.comded22402009-10-26 22:36:21 +000010
11urls = ('/', 'index',
12 '/update', 'update')
13
14app = web.application(urls, globals())
15render = web.template.render('templates/')
16
17
18class index:
19 def GET(self):
20 pkgs = buildutil.GetPackages()
21 return render.index(pkgs)
22
23class 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.com4dc25812009-10-27 23:46:26 +000031if __name__ == "__main__":
rtc@google.comded22402009-10-26 22:36:21 +000032 web.debug("Setting up the static repo")
dhg@google.com47660d82009-10-28 23:11:51 +000033 static_dir = os.path.realpath("%s/static" % os.path.dirname(os.path.abspath(sys.argv[0])))
chocobo@google.com4dc25812009-10-27 23:46:26 +000034 web.debug("Serving images from %s" % static_dir)
rtc@google.comded22402009-10-26 22:36:21 +000035 os.system("mkdir -p %s" % static_dir)
36 app.run()