render jinja2 template without a Flask context
问题 I have a Flask application that calls flask.render_template without problems when it is invoked from a flask http request . I need the same method to work outside of flask (from a python back end program) resolved_template = render_template(template_relative_path, **kwargs) I could use the jinja2 api , but I would like the same method to work, in both contexts (flask and command line) 回答1: You need to render it in an app context. Import your app in your backend code and do the following. with