0

Is it possible to use templates in Flask like in Bottle, without any external files? Just a template in a simple string variable. How would that work?

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187

1 Answers1

2

Use flask.render_template_string() to render a template stored in a string.

from flask import render_template_string

return render_template_string(
    '<body>{{ greeting }}</body>',
    greeting='Hello, World!')
Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187