from planet import create_app app = create_app('default') if __name__ == "__main__": app.run()
def create_app(self): app = create_app('testing') return app
current_app.logger.info('>>> 尝试从开彩网获取数据 <<<') res = self.fetch(self.kaicai_url, self.base_headers, json=True) if not res: current_app.logger.error('今日开彩网连接异常:{}'.format(self.today)) time.sleep(5) return self.back_up_response() data = res.get('data') current_app.logger.info('开彩网获得数据: {}'.format(data)) if not (isinstance(data, list) and len(data) > 0): time.sleep(5) return self.back_up_response() expect = data[0].get('expect') opencode = data[0].get('opencode') opentime = data[0].get('opentime') if opentime[:10] == str(self.today): resp = [opentime[:10], expect] resp.extend(opencode.split(',')) current_app.logger.info('kaicai return data:{}'.format(resp)) return resp time.sleep(5) return self.back_up_response() if __name__ == '__main__': from planet import create_app app, _ = create_app() with app.app_context(): # WelfareLottery().get_response() # WelfareLottery().back_up_response() WelfareLottery().kaicai_api()
if aca: user_act_code.update({'ACAid': aca.ACAid}) db.session.add(user_act_code) print({}.fromkeys(cratetime_list).keys()) def init_make_over(): with db.auto_commit(): mo = MakeOver.create({ 'Moid': 1, }) db.session.add(mo) if __name__ == '__main__': app = create_app() with app.app_context(): # admin = PermissionType.query.first_() # admin_str = json.dumps(admin, cls=JSONEncoder) # print(admin.__dict__) # print(admin_str) # make_acvitity() make_items() # make_permissiontype() # make_admin() # cexcel = CExcel() # filepath = r'D:\QQ\微信\file\WeChat Files\wxid_wnsa7sn01tu922\FileStorage\File\2019-03\product_insert.xlsx' # filepath = 'C:\Users\刘帅斌\Desktop\product_insert.xlsx' # cexcel.insertproduct(filepath) urllib.request.urlretrieve # cexcel._insertproduct(filepath) # add_product_promotion()