def get(self,sid): #if not form.validate_on_submit(): # return form.errors, 422 store = Store.query.filter_by(sid=sid).first_or_404() schema = StoreSchema() if store is not None: return Response(schema.dumps(store,indent=1).data,mimetype='application/json') return jsonify({"get":"fail"})
def get(self): stores = Store.query.all() schema = StoreSchema(many = True) store_list = schema.dump(stores).data for dic in store_list: st = Store.query.filter_by(storename=dic['storename']).first_or_404() if st.users.count() > 1: dic['holder'] = map(lambda x:x.username,list(st.users)) else: if list(st.users) != []: dic['holder'] = st.users[0].username else: continue return Response(json.dumps(store_list,indent=1),mimetype='application/json')