def peliculas(id=None): if request.method == "POST" and request.is_json: try: data = request.get_json() print(data) if insertar_pelicula(data): return jsonify({"code": "ok"}) else: return jsonify({"code": "no"}) except: return jsonify({"code": "error"}) elif request.method == "GET" and id is None: return jsonify(get_peliculas()) elif request.method == "GET" and id is not None: return jsonify(get_pelicula(id)) elif request.method == "PATCH" and id is not None and request.is_json: data = request.get_json() columna = data['columna'] valor = data['valor'] if modificar_pelicula(id, columna, valor): return jsonify(code='ok') else: return jsonify(code='error') elif request.method == "DELETE" and id is not None: if eliminar_pelicula(id): return jsonify(code='ok') else: return jsonify(code='ok')
def peliculas(id=None): if request.method == "POST" and request.is_json: try: data = request.get_json() print(data) if insertar_pelicula(data): return jsonify({"code": "ok"}) else: return jsonify({"code": "no"}) except: return jsonify({"code": "error"}) elif request.method == "GET" and id is None: return jsonify(get_peliculas()) elif request.method == "GET" and id is not None: return jsonify(get_pelicula(id))