def get(self,station_id): request = ProtobufAPI.GetStationFromIdRequest() flag = Helper.fillBaseRequest(request.baseRequest) if not flag: self.render('index.html',author = 'Error') request.station_id = station_id model = Model('GetStationFromId') response = model.communication(request) # 判断状态 if response.baseResponse.status != 0: if hasattr(response.baseResponse,'info'): self.render('index.html',author = response.baseResponse.info) else: self.render('index.html',author = 'Zeta - Error') # 解析 station 对象 station = self.parsingStation(response.stations) # 创建 request 对象 request = ProtobufAPI.GetServiceInStationRequest() flag = Helper.fillBaseRequest(request.baseRequest) if not flag: self.render('index.html',author = 'Error') model = Model('GetServiceInStation') response = model.communication(request) # 判断状态 if response.baseResponse.status != 0: if hasattr(response.baseResponse,'info'): self.render('index.html',author = response.baseResponse.info) else: self.render('index.html',author = 'Zeta - Error') services = self.parsingProduct(response.services) self.render('index.html',author = 'Zeta -JCheng')
def post(self): # 接收 POST 过来的数据 rawData = self.request.body # 创建 request 对象 request = ProtobufAPI.UserGetCouponRequest() # # 此处一定要对 request 对象进行赋值 # 例如: request.baserequest.sdk_version = 1 # model = Model('UserGetCoupon') response = model.communication(request) self.render('index.html', author='Zeta - JCheng')
def get(self): # 创建 request 对象 request = ProtobufAPI.GetStationForLocationRequest() flag = Helper.fillBaseRequest(request.baseRequest) if not flag: self.render('index.html', author='Error') # 判断经纬度 self.la = self.get_argument('la', 0) self.lo = self.get_argument('lo', 0) print 'la:' + str(la) print 'lo:' + str(lo) # 城市 id request.locate_id = 1 # 排序方式 request.sort = 1 # 刷新方式 request.refresh_direct = 1 # 加载的 station_id 偏移量 request.station_id = 1 if la != 0: request.latitude = la if lo != 0: request.longitude = lo # 通信 model = Model('GetStationForLocation') response = model.communication(request) # 判断状态 if response.baseResponse.status != 0: if hasattr(response.baseResponse, 'info'): self.render('index.html', author=response.baseResponse.info) else: self.render('index.html', author='Zeta - Error') # 解析 station 对象 station = self.parsingStation(response.stations) print station self.render('index.html', author='Zeta - Success')