change everything so it converts gpx to fit

This commit is contained in:
Friedemann 2024-09-15 15:04:53 +00:00
parent 0de5c680fc
commit 28333ed1bf
1 changed files with 4 additions and 4 deletions

8
app.py
View File

@ -8,7 +8,7 @@ app.secret_key = 'your_secret_key_here' # Required for flash messaging
INPUT_FOLDER = '/app/input'
OUTPUT_FOLDER = '/app/output'
ALLOWED_EXTENSIONS = {'fit'}
ALLOWED_EXTENSIONS = {'gpx'}
app.config['INPUT_FOLDER'] = INPUT_FOLDER
app.config['OUTPUT_FOLDER'] = OUTPUT_FOLDER
@ -31,15 +31,15 @@ def upload_file():
input_path = os.path.join(app.config['INPUT_FOLDER'], filename)
file.save(input_path)
output_filename = f"{os.path.splitext(filename)[0]}.gpx"
output_filename = f"{os.path.splitext(filename)[0]}.fit"
output_path = os.path.join(app.config['OUTPUT_FOLDER'], output_filename)
subprocess.run(['gpsbabel', '-i', 'garmin_fit', '-f', input_path, '-o', 'gpx', '-F', output_path])
subprocess.run(['gpsbabel', '-i', 'gpx', '-f', input_path, '-o', 'garmin_fit', '-F', output_path])
flash('File uploaded and converted successfully', 'success')
return redirect(url_for('upload_file'))
else:
flash('Invalid file type. Please upload a .fit file.', 'error')
flash('Invalid file type. Please upload a .gpx file.', 'error')
return redirect(url_for('upload_file'))
input_files = os.listdir(app.config['INPUT_FOLDER'])