title: Rest API working Fine on locally but not on Herkoku
body: <p>I tried to host a Flask Server on Heroku. I Worked Fine Locally and give me desired output that is json formatted List of Location in a city.When I hosted It on heroku it had build Successfully But it was not giving me my desired output.</p>
  <p>Please Help me And make me understand where i am going wrong</p>
  <p>When Working Locally The API gave me this Response</p>
  <p>API Call : <a href="http://127.0.0.1:5000/get_location_names_Bangalore" rel="nofollow noreferrer">http://127.0.0.1:5000/get_location_names_Bangalore</a></p>
  <pre><code>    {
      &quot;locations&quot;: [
      &quot;1st block jayanagar&quot;,
      &quot;1st phase jp nagar&quot;,
      &quot;2nd phase judicial layout&quot;,
      &quot;2nd stage nagarbhavi&quot;,
      &quot;5th block hbr layout&quot;,
      &quot;5th phase jp nagar&quot;,
      &quot;6th phase jp nagar&quot;,
      &quot;7th phase jp nagar&quot;,
      &quot;8th phase jp nagar&quot;,
      &quot;9th phase jp nagar&quot;,
      &quot;aecs layout&quot;,
      &quot;abbigere&quot;,
      &quot;akshaya nagar&quot;
     ]
  }
  </code></pre>
  <p>After Deploying Server To Heroku
  API call : https://xyz##########.herokuapp.com/get_location_names_Bangalore</p>
  <pre><code>{
  &quot;locations&quot;: null
  }
  </code></pre>
  <p>I am working with 2 file named server.py and util.py ....server.py is having necessary routes and util.py is having all neccasary function</p>
  <p>server.py</p>
  <pre><code>from flask import Flask, request, jsonify
  import util
  
  app = Flask(__name__)
  
  @app.route('/get_location_names_Bangalore', methods=['GET'])
  def get_location_names():
      response = jsonify({
          'locations': util.get_location_names()
      })
      response.headers.add('Access-Control-Allow-Origin', '*')
      
      return response
  
  
  @app.route('/predict_home_price_Bangalore', methods=['GET','POST'])
  def predict_home_price():
      total_sqft = float(request.form['total_sqft'])
      location = request.form['location']
      bhk = int(request.form['bhk'])
      bath = int(request.form['bath'])
  
      response = jsonify({
          'estimated_price': util.get_estimated_price(location,total_sqft,bhk,bath)
      })
      response.headers.add('Access-Control-Allow-Origin', '*')
  
      return response
  
  if __name__ == &quot;__main__&quot;:
      print(&quot;Starting Python Flask Server For Home Price Prediction...&quot;)
      util.load_saved_artifacts()
      app.run()
  </code></pre>
  <p>util.py</p>
  <pre><code>import json
  import pickle
  import numpy as np
  
  __location = None
  __data_columns = None
  __model = None
  
  
  def get_estimated_price(location,sqft,bhk,bath):
      try:
          loc_index = __data_columns.index(location.lower())
      except:
          loc_index = -1
  
      x = np.zeros(len(__data_columns))
      x[0] = sqft
      x[1] = bath
      x[2] = bhk
      if loc_index &gt;= 0:
          x[loc_index] = 1
  
      return round(__model.predict([x])[0],2)
  
  def get_location_names():
      return __location
  
  def load_saved_artifacts():
      print(&quot;Loading saved artifacts&quot;)
      global __location
      global __data_columns
  
      with open(&quot;bangalore_columns.json&quot;,'r') as f:
          __data_columns = json.load(f)['data_columns']
          __location = __data_columns[3:]
  
  
      global __model
      with open(&quot;banglore_home_prices_model.pickle&quot;,'rb') as f:
          __model = pickle._load(f)
  
          
  if __name__ == &quot;__main__&quot;:
      load_saved_artifacts()
      #print(get_location_names())
      #print(get_estimated_price('1st phase jp nagar',1000,3,3))
  </code></pre>
  <p>Requirement.txt</p>
  <pre><code>Flask==1.1.2
  gunicorn==20.0.4
  numpy==1.18.1
  </code></pre>
  <p>Procfile</p>
  <pre><code>web: gunicorn server:app
  </code></pre>