render jinja2 template without a Flask context

前端 未结 3 590
醉酒成梦
醉酒成梦 2021-01-02 03:59

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

3条回答
  •  猫巷女王i
    2021-01-02 04:34

    What I use is this code:

    import jinja2
    template_values = {
      'value_name_in_html': value_name_in_python,   
    }
    
    template = JINJA_ENVIRONMENT.get_template("file_patch")
    self.response.write(template.render(template_values))
    

提交回复
热议问题