Example #1
0
def get_actor_id_by_name(actor_name):
    """Return movie information of the given actor id"""
    actor = Actor.query.filter_by(actor_name=actor_name).first()
    if actor:
        return jsonify(row2dict(actor))
    else:
        return make_response(
            jsonify({
                "code": 404,
                "msg": "Cannot find any actor under this name."
            }), 404)
Example #2
0
def get_movie_by_actor_id(actor_id):
    """Return movie information of the given actor id"""
    movie = ActsIn.query.filter_by(actor_id=actor_id).first()
    if movie:
        return jsonify(row2dict(movie))
    else:
        return make_response(
            jsonify({
                "code": 404,
                "msg": "Cannot find any movies under this id."
            }), 404)
Example #3
0
def get_movie_by_studio_id(studio_id):
    """Return movie information of the given studio id"""
    movie = StudioOf.query.filter_by(studio_id=studio_id).first()
    if movie:
        return jsonify(row2dict(movie))
    else:
        return make_response(
            jsonify({
                "code": 404,
                "msg": "Cannot find any movies under this id."
            }), 404)
Example #4
0
def get_movie_by_genre_id(genre_id):
    """Return movie information of the given genre id"""
    movie = GenreOfMovie.query.filter_by(genre_id=genre_id).first()
    if movie:
        return jsonify(row2dict(movie))
    else:
        return make_response(
            jsonify({
                "code": 404,
                "msg": "Cannot find any movies under this id."
            }), 404)
Example #5
0
def get_all_movies():
    """Return information for all movies stored in the database"""
    movie_list = Movie.query.all()
    return jsonify([row2dict(movie) for movie in movie_list])