title: Flask web app get 'NoneType' object is not subscriptable
body: <p>Hello world I am writing a web application that gets information from API by passing a variable to the link to get its result and passing it to another link to get the final information to display it to the user, but this error continues to appear</p>
  <blockquote>
  <p>Traceback (most recent call last):   File
  &quot;c:\users\dreamer\appdata\local\programs\python\python39\lib\site-packages\flask\app.py&quot;,
  line 2447, in wsgi_app
  response = self.full_dispatch_request()   File &quot;c:\users\dreamer\appdata\local\programs\python\python39\lib\site-packages\flask\app.py&quot;,
  line 1952, in full_dispatch_request
  rv = self.handle_user_exception(e)   File &quot;c:\users\dreamer\appdata\local\programs\python\python39\lib\site-packages\flask\app.py&quot;,
  line 1821, in handle_user_exception
  reraise(exc_type, exc_value, tb)   File &quot;c:\users\dreamer\appdata\local\programs\python\python39\lib\site-packages\flask_compat.py&quot;,
  line 39, in reraise
  raise value   File &quot;c:\users\dreamer\appdata\local\programs\python\python39\lib\site-packages\flask\app.py&quot;,
  line 1950, in full_dispatch_request
  rv = self.dispatch_request()   File &quot;c:\users\dreamer\appdata\local\programs\python\python39\lib\site-packages\flask\app.py&quot;,
  line 1936, in dispatch_request
  return self.view_functionsrule.endpoint   File &quot;C:\Users\DREAMER\Desktop\project\app.py&quot;, line 50, in index
  name1 = movie[&quot;name&quot;] TypeError: 'NoneType' object is not subscriptable</p>
  </blockquote>
  <p>This is my code
  helpers.py</p>
  <pre><code>def lookupid(gen):
      &quot;&quot;&quot;Look up for Movies.&quot;&quot;&quot;
  
      url = &quot;https://imdb8.p.rapidapi.com/title/get-popular-movies-by-genre&quot;
  
      querystring = {&quot;genre&quot;:&quot;/chart/popular/genre/adventure&quot;}
  
      headers = {
          'x-rapidapi-key': &quot;d3c73c113emsh184235f8b4d5bc2p1bd515jsnf605a891b776&quot;,
          'x-rapidapi-host': &quot;imdb8.p.rapidapi.com&quot;
      }
  
      # Contact API
      try:
          response = requests.request(&quot;GET&quot;, url, headers=headers, params=querystring)
          response.raise_for_status()
      except requests.RequestException:
          return None
  
      # Parse response
      try:
          text = response.json()
          r = random.randint(0, 100)
          tit = text[r].split(&quot;/&quot;)[1:-1]
          return tit[1]
  
      except (KeyError, TypeError, ValueError):
          return None
  
  
  def lookupm(m_id):
      #---------------- Overview Information ---------------- t[r]
  
      url = &quot;https://imdb8.p.rapidapi.com/title/get-overview-details&quot;
  
      headers = {
          'x-rapidapi-key': &quot;d3c73c113emsh184235f8b4d5bc2p1bd515jsnf605a891b776&quot;,
          'x-rapidapi-host': &quot;imdb8.p.rapidapi.com&quot;
      }
      querystring = {&quot;tconst&quot;:&quot;{m_id}&quot;}
  
      # Contact API
      try:
          response = requests.request(&quot;GET&quot;, url, headers=headers, params=querystring)
          response.raise_for_status()
      except requests.RequestException:
          return None
  
      # Parse response
      try:
          over = response.json()
          return {
              &quot;name&quot;: over[&quot;title&quot;][&quot;title&quot;],
              &quot;imgurl&quot;: over[&quot;title&quot;][&quot;image&quot;][&quot;url&quot;],
              &quot;type&quot;: over[&quot;title&quot;][&quot;titleType&quot;],
              &quot;year&quot;: over[&quot;title&quot;][&quot;year&quot;],
              &quot;summary&quot;: over[&quot;plotSummary&quot;][&quot;text&quot;],
              &quot;genres&quot;: over[&quot;genres&quot;]
          }
  
      except (KeyError, TypeError, ValueError):
          return None
  </code></pre>
  <p>app.py</p>
  <pre><code>@app.route(&quot;/&quot;, methods=[&quot;GET&quot;,&quot;POST&quot;])
  def index():
      if request.method == &quot;GET&quot;:
          return render_template(&quot;home.html&quot;)
      else:
          mood = request.form[&quot;mood&quot;]
          titleid = lookupid(mood)
          movie = lookupm(titleid)
          name1 = movie[&quot;name&quot;]
          imgurl = movie[&quot;imgurl&quot;]
          type1 = movie[&quot;type&quot;]
          year = movie[&quot;year&quot;]
          summary = movie[&quot;summary&quot;]
          genres = movie[&quot;genres&quot;]
          return render_template(&quot;index.html&quot;, name=name1, imgurl=imgurl, type1=type1, year=year, summary=summary, genres=genres)
  </code></pre>
  <p>I take the first variable (gen) from the user by radio input.
  I do not know where the point of error is or I cannot discover it. Any help. I will be grateful for it. Thanks in advance.</p>