Yh
from flask import Flask, render_template, request, send_file
from werkzeug.utils import secure_filename
import os
from pydub import AudioSegment
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'uploads/'
app.config['CONVERTED_FOLDER'] = 'converted/'
@app.route('/')
def index():
return render_template('index.html')
@app.route('/convert', methods=['POST'])
def convert():
file = request.files['file']
filename = secure_filename(file.filename)
input_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
file.save(input_path)
# WAV/FLAC ஐ MP3 ஆக மாற்றுதல்
output_path = os.path.join(app.config['CONVERTED_FOLDER'], f"{filename}.mp3")
audio = AudioSegment.from_file(input_path)
audio.export(output_path, format="mp3")
return send_file(output_path, as_attachment=True)
if __name__ == '__main__':
app.run(debug=True)
Comments
Post a Comment