How to set specific directory for Render_template flask?

Asked

Viewed 35 times

-2

I am rendering an html report using the Flask render_template. By default render_template renders what is in the template folder, however, I need to change to make the directory another. I tried to force a default directory but did not succeed.

from flask import Blueprint, request, jsonify, send_from_directory, render_template, Flask

admin = Blueprint('admin', __name__, template_folder='././production/fiscal/relatorios')

return render_template(apuracao.html)
  • 1

    File name should be in quotes.

1 answer

-1

app = Flask(name, template_folder="views")

This "views", in this case is the name in which I changed from templates to views. So, you will have to change the name to views in the directory. (views was a suggestive name. you change the directory according to the name you give in "template_folder="name you want to change")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.