def new_movies(): title = request.args.get('title', '') rating = request.args.get('rating', '') if title == '' or rating == '': abort(400) if Movies.query.filter_by(title=title).first() is not None: return jsonify({"message": "movie alaredy exists"}), 200 movie = Movies(title=title) movie.rating = rating db.session.add(movie) db.session.commit() #showtime_req = requests.post(showtime_post+'?'+'id='+str(movie.id)) showtime_req = requests.post(showtime_post + '?' + 'id=' + str(movie.id) + '&title=' + str(title) + '&rating=' + str(rating)) print(showtime_req.text) return jsonify({ 'Title': movie.title, 'Raiting': movie.rating, 'id': movie.id })
def add_movie(): id = request.args.get('id','') title = request.args.get('title','') rating = request.args.get('rating','') if title == '' or rating== '': abort(400) if Movies.query.filter_by(title=title).first() is not None: return jsonify({"message":"movie alaredy exists in showtime Database"}), 200 movie = Movies(title=title) movie.id = id movie.rating=rating db.session.add(movie) db.session.commit() return 'Movie added in the showtime service'
from models import Movies from settings import db # m = Movies(title=i) # m.rating=movies[i] # db.session.add(m) # db.session.commit() m2 = Movies(title='Dragon Ball') m2.rating = 2 db.session.add(m2) db.session.commit() m3 = Movies(title='FightClub') m3.rating = 10 db.session.add(m3) db.session.commit() m4 = Movies(title='Batman') m4.rating = 5 db.session.add(m4) db.session.commit() print('Done..')
from models import Movies, Dates, showtime from settings import db from datetime import date, datetime import pytz ######Movies################### m = Movies(title='Titanic') m.rating = 9 db.session.add(m) db.session.commit() m2 = Movies(title='Dragon Ball') m2.rating = 2 db.session.add(m2) db.session.commit() m3 = Movies(title='FightClub') m3.rating = 10 db.session.add(m3) db.session.commit() m4 = Movies(title='Batman') m4.rating = 5 db.session.add(m4) db.session.commit() ######Movies################### # m = Movies(id=1) # db.session.add(m)