def get_chapter(version,book,chnum): try: v = version.upper() b = clean_book_abbr(book) if request.method == 'GET': x = controller.get_chapter(v,b,chnum) return x elif request.method == 'POST': x = controller.add_verse(v,b,chnum) return x except (NotFoundException,BadDataException,AlreadyExistsException) as e: print(tb.format_exc()) abort(e.code) except Exception: print(tb.format_exc()) abort(500)
def handle_verse(version,book,chnum,verse): try: data = parse_verse_path(version,book,chnum,verse) if request.method == 'GET': return controller.get_verse(**data) elif request.method == 'POST': request.form = {'number':data['verse_a'],'text':request.form['text']} return controller.add_verse(**data) elif request.method == 'PUT': return controller.set_verse(**data) elif request.method == 'DELETE': return controller.rm_verse(**data) except (NotFoundException,BadDataException,AlreadyExistsException) as e: abort(e.code) except Exception: print(tb.format_exc()) abort(500)