[Python] API stopped working after adding a a user.db (login, register, logout)

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    I'm new to working with API´s.

    So basically I send data but that data doesn't get recognized or at least when I do print(requests.form) it doesn't show the file only some floats that I send along and my hole code runs till the end but when it returns it says the file was not found.

    The code was working before adding the user authentication it was working well, I already checked if the endpoints were correct and they are, in the end I receive a error that says the x file was not found

    @bp.route('/tts', methods=['POST'])
    def tts():
    try:
    print(request.form)

    filepath = request.files['filepath']
    pitch = float(request.form.get('pitch', 0))
    speech_rate = float(request.form.get('speech_rate', 1))



    file_extension = secure_filename(filepath.filename)
    file_content = os.path.join(UPLOAD_FOLDER, file_extension)
    filepath.save(file_content)

    output = post_process(filecontent, pitch, speech_rate)

    return send_file(output, as_attachment=True, mimetype='audio/mp3',download_name=f'Processed {filename}.mp3'), 200


    HTML

    <form id="tts" enctype="multipart/form-data" method="post" action="http://localhost:5000/tts">


    <label for="filepath">Select File:</label><br>
    <input type="file" required id="filepath" name="filepath" accept=".txt,.srt,.ssml"><br><br>

    Continue reading...

Compartilhe esta Página