예제 #1
0
def main():
    global db
    movie_db = load_movies("../ml-100k/u.item")
    load_genres(movie_db, "../ml-100k/u.genre")
    user_db = load_users("../ml-100k/u.user")
    ratings_db = load_ratings("../ml-100k/u.data")

    db = movies.connect_db("dbh36.mongolab.com", 27367, "movie_user", "password", "movies")
    #db = pymongo.connection.Connection("localhost")
    db = db['movies']

    #push_to_mongo(db, "movies", movie_db)
    #push_to_mongo(db, "users", user_db)
    push_ratings(db, ratings_db)

    preloaded = [
        (71, 5),
        (72, 4),
        (588, 5),
        (1014, 4),
        (541, 5),
        (543, 5),
        (42, 4),
        (83, 5),
        (82, 5),
        (88, 2),
        (739, 2)
            ]


    movies.db = db
    for movie,rating in preloaded:
        movies.rate_movie(movie, rating)
예제 #2
0
파일: webapp.py 프로젝트: wendiewang/movies
def rate_movie():
    rate_movie = movies.rate_movie(int(request.form["movie_id"]), int(request.form["rating"]))
    return render_template("rate_movie.html", rate_movie=rate_movie)