当前位置: 首页>>代码示例>>Python>>正文


Python api_functions.CronosDB类代码示例

本文整理汇总了Python中api_functions.CronosDB的典型用法代码示例。如果您正苦于以下问题:Python CronosDB类的具体用法?Python CronosDB怎么用?Python CronosDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CronosDB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_suggestion

def get_suggestion(user_id):
  db = CronosDB("root", "zerl", "cronos")
  response.headers['Content-Type'] = 'application/json'
  movies = db.get_likes_hash(user_id)
  for movie in movies:
    movie["youtube_id"] = movie["url"].split("=")[-1]
  return json.dumps(movies)
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:7,代码来源:api.py

示例2: show_movie_by_subgenre

def show_movie_by_subgenre(genre_name, subgenre_name):
  db = CronosDB("root", "zerl", "cronos")
  response.headers['Content-Type'] = 'application/json'
  movies = db.get_movies_by_genre_subgenre(genre_name, subgenre_name);
  for movie in movies:
    movie["youtube_id"] = movie["url"].split("=")[-1]
  return json.dumps(movies)
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:7,代码来源:api.py

示例3: show_movie_by_actor

def show_movie_by_actor(actor_name):
  db = CronosDB("root", "zerl", "cronos")
  response.headers['Content-Type'] = 'application/json'
  actor_name = actor_name.replace(":", " ")
  movies = db.get_movies_by_actor(actor_name);
  for movie in movies:
    movie["youtube_id"] = movie["url"].split("=")[-1]
  return json.dumps(movies)
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:8,代码来源:api.py

示例4: get_rating_by_movie

def get_rating_by_movie(movie_id):
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    return json.dumps(db.get_rating_by_movie(movie_id))
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:10,代码来源:api.py

示例5: update_rating

def update_rating(user_id, movie_id, rating):
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    info = db.update_rating(user_id, movie_id, rating)
    return json.dumps(info)
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:11,代码来源:api.py

示例6: add_movie_trans

def add_movie_trans():
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    try:
      data = json.load(request.body)
    except Exception as error:
      raise ValueError("Cannot parse request: {0}".format(error))
    if data is None:
      raise ValueError("Request is None")
    result = db.add_movie_trans(data["movie_id"], data["other_id"], data["trans_name"])
    return json.dumps({'result': result})
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:17,代码来源:api.py

示例7: add_award_category

def add_award_category(award_id):
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    try:
      data = json.load(request.body)
    except Exception as error:
      raise ValueError("Cannot parse request: {0}".format(error))
    if data is None:
      raise ValueError("Request is None")
    nom_id = db.add_award_nomination(data['category_id'], data['actor_id'], data['year'], data['won'], data["movie"])
    return json.dumps({'nom_id': nom_id})
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:17,代码来源:api.py

示例8: add_user

def add_user():
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    try:
      data = json.load(request.body)
    except Exception as error:
      raise ValueError("Cannot parse request: {0}".format(error))
    if data is None:
      raise ValueError("Request is None")
    user_id = db.add_user(data["name"], data["password"], data["email"])
    return json.dumps({'user_id': user_id})
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:17,代码来源:api.py

示例9: update_award_category

def update_award_category(award_id, nom_id):
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    try:
      data = json.load(request.body)
    except Exception as error:
      raise ValueError("Cannot parse request: {0}".format(error))
    if data is None:
      raise ValueError("Request is None")
    if not db.update_award_nomination(nom_id, data["category_id"], data["actor_id"], data["year"], data["won"], data["movie"]):
      raise ValueError("Cannot award nomination {0}-{1}-{2}-{3}-{4}".format(nom_id, data["category_id"], data["actor_id"], data["year"], data["won"]))
    return json.dumps(db.get_award_nomination_by_id(nom_id))
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:18,代码来源:api.py

示例10: update_movie

def update_movie(movie_id):
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    try:
      data = json.load(request.body)
    except Exception as error:
      raise ValueError("Cannot parse request: {0}".format(error))
    if data is None:
      raise ValueError("Request is None")
    if not db.update_movie(data):
      raise ValueError("Cannot update movie{0}".format(data))
    return json.dumps(db.get_movie_by_id(movie_id))
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:18,代码来源:api.py

示例11: update_user

def update_user(user_id):
  response.headers['Content-Type'] = 'application/json'
  db = CronosDB("root", "zerl", "cronos")
  try:
    try:
      data = json.load(request.body)
    except Exception as error:
      raise ValueError("Cannot parse request: {0}".format(error))
    if data is None:
      raise ValueError("Request is None")
    if not db.update_user(user_id, data["name"], data["password"], data["email"], data["admin"]):
      raise ValueError("Cannot update user {0}".format(user_id))
    return json.dumps(db.get_user_by_id(user_id)[0])
  except ValueError as error:
    msg =  "Exception...{0}".format(error)
    response.status = 400
    print msg
    return json.dumps({"status": 400, "msg": msg})
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:18,代码来源:api.py

示例12: show_studios

def show_studios():
  db = CronosDB("root", "zerl", "cronos")
  response.headers['Content-Type'] = 'application/json'
  return json.dumps(db.get_studios())
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:4,代码来源:api.py

示例13: show_award_nominations_by_year_category

def show_award_nominations_by_year_category(award_id, year, category_id):
  db = CronosDB("root", "zerl", "cronos")
  response.headers['Content-Type'] = 'application/json'
  return json.dumps(db.get_award_nominations_by_year_category(award_id, year, category_id))
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:4,代码来源:api.py

示例14: show_awards

def show_awards():
  db = CronosDB("root", "zerl", "cronos")
  response.headers['Content-Type'] = 'application/json'
  return json.dumps(db.get_all_nominations_categories())
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:4,代码来源:api.py

示例15: show_movie_view_by_id

def show_movie_view_by_id(movie_id):
  db = CronosDB("root", "zerl", "cronos")
  response.headers['Content-Type'] = 'application/json'
  return json.dumps(db.get_movie_view_info(movie_id))
开发者ID:Zerl1990,项目名称:CronosDB,代码行数:4,代码来源:api.py


注:本文中的api_functions.CronosDB类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。