Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 python 3.7 on windows using flask and flask-sqlalchemy.
[url=]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():
    if  request.method == 'POST':
        def search(title):
            search = tmdb.Search()
            response =
            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'],


    return render_template('myMovies.htm')
File "c:\users\alefg\projects\mytop100movies\venv\lib\site-packages\flask\", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Users\alefg\projects\MyTop100Movies\src\blueprint\", line 21, in post_movies m = search('The Bourne') File "C:\Users\alefg\projects\MyTop100Movies\src\blueprint\", line 18, in search record.append((infos['title'], infos['release_date'], infos['popularity'])) TypeError: string indices must be integers
with this line:
info = json.dumps(search.results)
you serialize search.results to JSON formatted string and then later here:
record.append((infos['title'], infos['release_date'], infos['popularity']))
you try to access it's keys like it's dictionary, which causes the error shown

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Flask, Display a picture outisde the static SpongeB0B 1 61 Aug-07-2020, 09:53 PM
Last Post: snippsat
  Flask formatting into HTML engineer_geek 1 106 Aug-05-2020, 01:51 AM
Last Post: engineer_geek
  show csv file in flask template.html rr28rizal 6 21,560 Jul-29-2020, 05:02 PM
Last Post: morph10
  Sending How to send private message with Flask-Socketio and Vue jonte 0 122 Jul-28-2020, 08:14 PM
Last Post: jonte
  filtering by category flask+mongodb Leon79 3 211 Jul-19-2020, 04:25 AM
Last Post: ndc85430
  Flask Ubuntu Server Not Running Wheel 0 176 Jul-14-2020, 08:12 PM
Last Post: Wheel
  flask How to output stderr and exceptions to log file umen 4 991 Jun-20-2020, 06:11 AM
Last Post: umen
  Flask export/upload database table in cvs/xlsx format steve87bg 4 235 Jun-19-2020, 01:46 PM
Last Post: steve87bg
  Build a simple Webapp with Python Flask and mariaDB newbie1 3 341 Jun-04-2020, 09:34 PM
Last Post: lmolter54
  Flask deployment from heck lmolter54 4 297 Jun-04-2020, 09:08 PM
Last Post: lmolter54

Forum Jump:

Users browsing this thread: 1 Guest(s)