'How to add multiple path locations in flask

i was thinking to simulate a disk full situation. so that after certain number of files gets uploaded into one location it will automatically switch to different path.

@application.route("/uploader" , methods=['GET', 'POST'])
def uploader():
    count = 0
    if (count < 3):
        if request.method=='POST':
            f = request.files['file1']
            f.save(os.path.join(application.config['UPLOAD_FOLDER1'], secure_filename(f.filename)))
            count = count + 1
            return "Uploaded successfully!"
    else:
        if request.method=='POST':
            f = request.files['file2']
            f.save(os.path.join(application.config['UPLOAD_FOLDER2'], secure_filename(f.filename)))
            return "Uploaded successfully!"

but it refuses to go to other provided locations.



Solution 1:[1]

import pandas as pd
import glob 

from datetime import datetime

all_files = glob.glob("*.csv")

li=[]

for filename in all_files:
    df= pd.read_csv(filename,index_col=0,header=0)
    li.append(df)

# sometimes working with pandas functions can
# make your code long and complicated for no reason.
# See my for loop below which classifies your dist and time.

    for data in df.values:
        distance = data[0]
        time = datetime.strptime(data[1], '%H:%M:%S').time()
        if distance >= 100:
            print('should be red')
            #write value to csv here
        else:
            print('should be blue')
            #write value to csv here
        
        if time >= datetime.strptime('03:00:00', '%H:%M:%S').time():
            print('Should be red')
            #write value to csv here
        else:
            print('Should be blue')
            #write value to csv here
            
    
    # total_distance = pd.concat(li,axis=0,ignore_index=True)
    # total_distance1 = total_distance[['distance']]
    # total_distance1 = (total_distance1).iloc[-1]

    # total_distance1 = (total_distance1).astype(int)

    # if total_distance1 >= 200:
    #     total_distance['color_dist'] = 'red'
    #     total_distance.to_csv(filename,index=False)
    # else:
    #     total_distance['color_dist'] = 'blue'
    #     total_distance.to_csv(filename,index=False)

    break

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1