def get_libraries(): library = Library() library.library_id = 1 library.name = '분당도서관' library.website = 'http://bd.snlib.net' library.image = 'http://tong.visitkorea.or.kr/cms/resource/31/1785931_image2_1.jpg' library2 = Library() library2.library_id = 2 library2.name = '성남중앙도서관' library2.website = 'http://ct.snlib.net' library2.image = 'http://tong.visitkorea.or.kr/cms/resource/49/1785949_image2_1.jpg' result = {} libraries = [] libraries.append(library.to_json()) libraries.append(library2.to_json()) # result['libraries'] = libraries result_str = json.dumps(libraries, ensure_ascii=False) # try: # result_str = jsonify(libraries=libraries) # except Exception, e: # print e # print result.to_json() response = make_response(result_str) response.headers['Content-Type'] = 'application/json;charset=UTF-8' response.headers['Access-Control-Allow-Credentials'] = 'true' response.headers['Access-Control-Allow-Origin'] = '*' return response
def get_library(library_id): library = Library() library.library_id = 1 library.name = '분당도서관' library.website = 'http://bd.snlib.net' library.image = 'http://tong.visitkorea.or.kr/cms/resource/31/1785931_image2_1.jpg' result_str = json.dumps(library.to_json(), ensure_ascii=False) response = make_response(result_str) response.headers['Content-Type'] = 'application/json;charset=UTF-8' response.headers['Access-Control-Allow-Credentials'] = 'true' response.headers['Access-Control-Allow-Origin'] = '*' return response