示例#1
0
 def GET(self):
     util = Util()
     inputdata = web.input()
     if hasattr(inputdata, 'id'):
         lottery_id = inputdata.id
         item = util.getLottery(_id = inputdata.id)
         if item: return item.stringify()
         else: return web.notfound("lottery not found")
     else:
         ps = int(inputdata.ps) if hasattr(inputdata, 'ps') else 0
         pn = int(inputdata.pn) if hasattr(inputdata, 'pn') else 10
         pe = ps + pn - 1
         items = util.getAllLotteries(ps, pe)
         lottery_cnt = util.getLotteryCount()
         if not items is None: return '{' + '"data": [{0}], "ps": {1}, "pn": {2}, "total": {3}'.format(", ".join([i.stringify() for i in items]), ps, pn, lottery_cnt) + '}'
         else: return web.notfound("lotteries not found")