Python Forum
python 3.7 on windows using flask and flask-sqlalchemy.
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
def search(title):
          search = tmdb.Search()
          response =
          record = []
          for info in search.results:
          return record

Possibly Related Threads…
Thread Author Replies Views Last Post
  new window in separate thread - flask website Notabene 0 64 Sep-15-2021, 06:41 AM
Last Post: Notabene
  IndexError: list index out of range" & "TypeError: The view function f: Flask Web App joelbeater992 5 270 Aug-31-2021, 08:08 PM
Last Post: joelbeater992
  How do you define and -put a value into a variable in Flask? a4ginatl 10 1,134 Aug-15-2021, 03:07 PM
Last Post: a4ginatl
  Flask web app on Azure help dangermaus33 2 962 Aug-10-2021, 12:04 PM
Last Post: kashcode
Question Deploy Flask apps on Windows... SpongeB0B 2 281 Aug-08-2021, 09:12 AM
Last Post: ndc85430
  Flask TypeError: Object of type Decimal is not JSON serializable mekacharan 0 574 Jul-15-2021, 05:28 AM
Last Post: mekacharan
  Flask read real time print from subprocess without deadlock vofka32 0 504 Jun-02-2021, 09:36 AM
Last Post: vofka32
Question running Flask with waitress having web traffic log... SpongeB0B 2 883 May-06-2021, 07:07 AM
Last Post: SpongeB0B
Question problems with flask and celery Phantomsec 2 1,471 Apr-28-2021, 07:30 PM
Last Post: Phantomsec
  Error updating one to many relationship in Flask/ SQLAlchemy atindra 0 879 Apr-15-2021, 10:29 PM
Last Post: atindra

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020