Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Friedemann | 8442923dbd | |
Friedemann | 28333ed1bf |
8
app.py
8
app.py
|
@ -8,7 +8,7 @@ app.secret_key = 'your_secret_key_here' # Required for flash messaging
|
||||||
|
|
||||||
INPUT_FOLDER = '/app/input'
|
INPUT_FOLDER = '/app/input'
|
||||||
OUTPUT_FOLDER = '/app/output'
|
OUTPUT_FOLDER = '/app/output'
|
||||||
ALLOWED_EXTENSIONS = {'fit'}
|
ALLOWED_EXTENSIONS = {'gpx'}
|
||||||
|
|
||||||
app.config['INPUT_FOLDER'] = INPUT_FOLDER
|
app.config['INPUT_FOLDER'] = INPUT_FOLDER
|
||||||
app.config['OUTPUT_FOLDER'] = OUTPUT_FOLDER
|
app.config['OUTPUT_FOLDER'] = OUTPUT_FOLDER
|
||||||
|
@ -31,15 +31,15 @@ def upload_file():
|
||||||
input_path = os.path.join(app.config['INPUT_FOLDER'], filename)
|
input_path = os.path.join(app.config['INPUT_FOLDER'], filename)
|
||||||
file.save(input_path)
|
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)
|
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')
|
flash('File uploaded and converted successfully', 'success')
|
||||||
return redirect(url_for('upload_file'))
|
return redirect(url_for('upload_file'))
|
||||||
else:
|
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'))
|
return redirect(url_for('upload_file'))
|
||||||
|
|
||||||
input_files = os.listdir(app.config['INPUT_FOLDER'])
|
input_files = os.listdir(app.config['INPUT_FOLDER'])
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<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.tailwindcss.com"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||||
<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="max-w-4xl mx-auto bg-white rounded-lg shadow-xl overflow-hidden animate-fadeIn">
|
||||||
<div class="bg-blue-600 text-white p-6">
|
<div class="bg-blue-600 text-white p-6">
|
||||||
<h1 class="text-3xl font-bold mb-2">FIT to GPX Converter</h1>
|
<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>
|
||||||
|
|
||||||
<div class="p-6">
|
<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">
|
<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>
|
<h2 class="font-bold text-lg mb-2">Quick Start Guide</h2>
|
||||||
<ol class="list-decimal list-inside space-y-1">
|
<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>Click the "Upload and Convert" button.</li>
|
||||||
<li>Wait for the conversion to complete.</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>
|
</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>
|
</div>
|
||||||
|
|
||||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
Delete Selected Input Files
|
Delete Selected Input Files
|
||||||
</button>
|
</button>
|
||||||
{% else %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue