Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
how to get the return value of a view function in flask with XMLHttpRequest from javascript

I cannot retrieve the transcript value with javascript using XMLHttpRequest, what's wrong with my code? everything works fine but i need the return value of transcript variable which is a long text

@app.route("/transcribe", methods=['POST'])
def transcribe():
        transcript = ""
        videos = glob.glob("static/uploads/video/*")
        ToEmptyDir()
        for video in videos:
            prs = parse_seconde(video)
            transcript = cut_video(prs, video).lstrip()
            insertToFile(video.split("\\")[1].split(".")[0], transcript)
        txtFile = glob.glob(os.getcwd() + "/*.txt")
        return transcript

index.html :

<button type="button" id="transcribe" onclick="loadTranscribeFile()"> Transcribe </button>
<script>
     function loadTranscribeFile(callback) {
             var req = new XMLHttpRequest();
             req.open('POST', '/transcribe', true);
             req.responseType = 'json';
             req.send("textTranscribed=" + document.getElementById('textTranscribed').value);
     }
</script>  
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

try this

req.onreadystatechange = function(res){
        if (req.readyState == 4 && req.status == 200){
        var t = JSON.parse(req.responseText)
        console.log(t);
        }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!