def post(self): data = ApiUrl.parser.parse_args() print('you are here') url = Url(data['login_url'], data['visit_url']) try: url.save_to_db() except: return {'message' : 'Failed to save'}, 500 return url.json(), 201
def put(self, id): data = ApiUrl.parser.parse_args() url = Url.find_by_id(id) if url is None: url = Url(data['login_url'], data['visit_url']) else: url.login_url = data['login_url'] url.visit_url = data['visit_url'] url.save_to_db() return url.json()
def get(self): urls = Url.find_all(Url) return {'urls' : [Url.json(myInput) for myInput in urls]}