Jul-23-2020, 07:25 PM
[url=https://github.com/celiao/tmdbsimple/]API used[/url] #I can't extract data from an API arrow and add it to my database @blueprintRote.route('/', methods =['GET','POST']) def post_movies(): #POST if request.method == 'POST': def search(title): search = tmdb.Search() response = search.movie(query=title) info = json.dumps(search.results) record = [] for infos in info: record.append((infos['title'], infos['release_date'], infos['popularity'])) return record m = search('The Bourne') new_user = Movies(title=m['title'], release_date=m['release_date'],popularity=m['popularity']) db.session.add(new_user) db.session.commit() return render_template('myMovies.htm')
Error:File "c:\users\alefg\projects\mytop100movies\venv\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\alefg\projects\MyTop100Movies\src\blueprint\blueprintsRoutes.py", line 21, in post_movies
m = search('The Bourne')
File "C:\Users\alefg\projects\MyTop100Movies\src\blueprint\blueprintsRoutes.py", line 18, in search
record.append((infos['title'], infos['release_date'], infos['popularity']))
TypeError: string indices must be integers