1

I have two flask routes as shown below. While testing locally the value of the global variables seems to be retained between the routes. After deploying to Heroku however, this is not the case, specifically, my DataFrame contains some other months also. Again, it works perfectly when I run it on localhost. Why is this happening and how to correct this?

df_orig = None
df = None


@app.route('/getDF')
def getDF():
    global df, df_orig 
    #read some data into df_orig
    df_orig = pd.read_csv('data1.csv')
    df = df_orig.copy()
    df = df[df['month'] == 6]  
    return render_template ......

@app.route('/useDF')
def useDF():
    global df
    #value of df here does not reflect changes made in prev route

    return render_template ......
hiddenfile
  • 23
  • 4

0 Answers0