Compare commits

...

2 Commits

2 changed files with 10 additions and 10 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'])

View File

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FIT to GPX Converter</title>
<title>GPX to FIT Converter</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<script>
@ -54,19 +54,19 @@
<div class="max-w-4xl mx-auto bg-white rounded-lg shadow-xl overflow-hidden animate-fadeIn">
<div class="bg-blue-600 text-white p-6">
<h1 class="text-3xl font-bold mb-2">FIT to GPX Converter</h1>
<p class="text-lg">Convert your .fit files to .gpx format with ease!</p>
<p class="text-lg">Convert your .gpx files to .fit format with ease!</p>
</div>
<div class="p-6">
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4 mb-6 rounded animate-fadeIn" role="alert">
<h2 class="font-bold text-lg mb-2">Quick Start Guide</h2>
<ol class="list-decimal list-inside space-y-1">
<li>Select a .fit file using the file input below.</li>
<li>Select a .gpx file using the file input below.</li>
<li>Click the "Upload and Convert" button.</li>
<li>Wait for the conversion to complete.</li>
<li>Download your converted .gpx file from the output files list.</li>
<li>Download your converted .fit file from the output files list.</li>
</ol>
<p class="mt-2">This tool converts Garmin FIT files to GPX format, allowing you to use your fitness data in a wide range of applications and devices.</p>
<p class="mt-2">This tool converts GPX files to Garmin FIT format, allowing you to use your fitness data in a wide range of applications and devices like garminDB importer.</p>
</div>
{% with messages = get_flashed_messages(with_categories=true) %}
@ -104,7 +104,7 @@
Delete Selected Input Files
</button>
{% else %}
<p class="text-gray-600">No input files yet. Upload a .fit file to get started!</p>
<p class="text-gray-600">No input files yet. Upload a .gpx file to get started!</p>
{% endif %}
</div>