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?
Asked
Active
Viewed 403 times
0
-
simple Flask example would be appreciate:) – user3647585 May 18 '14 at 13:20
1 Answers
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