Forums

[Flask] render template does not run

Account type: custom; language: python3.8

In a post method request, a function called separate eventually adds a folder to my file directory. After that render template is supposed to run, but it is not running. The print function below was displayed in the server log.

    # separate stems
    separate(filename)

    print("above function is done but render template doesn't run")
    return render_template("download.html")

For anyone who is curious, the separate function runs ML on a file:

def separate(filename):
    from spleeter.separator import Separator
    separator = Separator('spleeter:2stems')
    separator.separate_to_file(os.path.join(app.root_path, app.config['UPLOAD_FOLDER'], filename), os.path.join(app.root_path, app.config['STEMS_FOLDER']))

To be clear, the render_template function works when it is directly above the separate function. Has anyone ever experienced this before? I would greatly appreciate any suggestions to move forward, thanks.

That sounds strange. When you say it's not running, what is the render_template doing -- raising an exception, returning an empty, page, or something else?

Thank you for replying. The render_template isn't returning anything it seems.

After adding the below code:

    try:
        print("in the try...")
        return render_template("download.html", filename=relative_fp, zipfile_name=zip_filepath)
    except:
        print("not working......")

In the server log I see this: 2021-04-17 17:38:34 in the try...

What I found strange is that when I click 'Reload' on the Web section, the site reloads to the html page render_template is directing to. Is there a way to do a refresh like that in Flask?

To be clear, there are no errors notified in the error logs. It makes me think if some other process is overriding render_template() but I can't wrap my head around what that might be.

Can you post the contents of the download.html template? Or if it's quite large, or contains things that you don't want to share on these public forums, perhaps we can take a look at your code from our admin interface? We can see it from there, but we always ask for permission first.

When time allows could you please take a look at my code? I'm not sure download.html is the issue because all that offers really is a button to download a file. Because I came to the end of my wits here, I'm trying to duplicate this issue on Heroku. The only issue so far is that I can't push the repo because the repo size exceeds 1 GB.

@lkstandsfor I can't find that in your code. Could you send detail of where to look for it to support@pythonanywhere.com ?