def post_movie(): movie = Movie() movie.runtime = request.json.get('runtime') movie.director = request.json.get('director') movie.country = request.json.get('country') movie.genre = request.json.get('genre') movie.launch_date = request.json.get('launch_date') movie.movie_title = request.json.get('movie_title') movie.save() return movie.to_json(), 200
def add_movie(payload): try: body = request.get_json() similar_movie_flag = Movie.query.filter( Movie.title == body.get('title')).one_or_none() if similar_movie_flag is not None: return jsonify({ 'message': 'Similar Movie Title Already Exist in Database.' }), 422 new_movie = Movie( title=body.get('title'), desc=body.get('desc'), release_date=body.get('release_date') ) new_movie.save() return jsonify({ 'movie': new_movie.to_json(), 'success': True }), 201 except Exception: abort(500)