目前,我正在使用以下代码
app = Flask(__name__, template_folder=os.path.abspath(os.path.dirname(__file__)[:-4] + 'templates'))但这看起来太愚蠢了。我想问一下,是否有等效的代码来替代它?
顺便说一句,我试过了
app = Flask(__name__, template_folder='../flask-WTF/templates))但这是行不通的。
我的文件结构是:file-structure
发布于 2019-06-17 16:35:44
你应该写下:
app = Flask(__name__, template_folder='../templates'))此外,您还可以尝试:
os.chdir('..')
app = Flask(__name__, template_folder = os.getcwd() + '/templates'))https://stackoverflow.com/questions/56623443
复制相似问题