def api(): # POST请求:传递types和polygon给后端处理 if request.method == 'POST': types = request.form['types'] polygon = request.form['polygon'] if request.form['do'] == 'lbs': icd = IceDrumstick(types=types, polygon=polygon) icd.save_to_db() im = IceMap(types=types, polygon=polygon) im.save_data() icr = IceRecord(types=types, polygon=polygon) icr.save_to_db() return icr.rid else: ph = PolygonHelper(polygon) th = TypeHelper(types) return ph.get_hash() + th.get_hash() # GET请求 # do=view: 返回数据给前端展示 if request.method == 'GET': tid = request.args.get('tid') rid = request.args.get('rid') if request.args.get('do') == 'view': pc = PoiCtrl(tid=tid, rid=rid) return Response(json.dumps(pc.get_location()), mimetype='application/json') # do=excel: 生成excel表 elif request.args.get('do') == 'excel': ec = ExcelCtrl(tid=tid, rid=rid) return ec.save_to_xlsx()
def _set_record(self): ph = PolygonHelper(self.polygon) self.polygon = ph.to_str() self.center = ph.get_center_str() th = TypeHelper(self.types) self.types = th.to_str() self.tids = th.get_tids_str() self.rid = ph.get_hash() + th.get_hash()
def __init__(self, **kwargs): types = kwargs.get('types', '050000') polygon = kwargs.get('polygon', '120.107076,30.326175;120.085948,30.316822;') th = TypeHelper(types) ph = PolygonHelper(polygon) self.types_list = th.to_list() self.polygon = ph.to_str() self.rid = ph.get_hash() + th.get_hash() self.key = 'e444f2d824f09ff1708854c1e66d0e19' self.offset = 20 self.url = 'http://restapi.amap.com/v3/place/polygon' self.lock = threading.Lock()
def __init__(self, **kwargs): polygon = kwargs.get('polygon', '') types = kwargs.get('types', '') ph = PolygonHelper(polygon) th = TypeHelper(types) self.rid = ph.get_hash() + th.get_hash()