Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Render A Template String In Python's flask Web Server

Code

#!/usr/bin/env python3

from flask import Flask
from flask import render_template_string

app = Flask(__name__)

@app.route('/')
def index():
    return render_template_string("""
<!DOCTYPE html>
<html><head><title>CSS Test</title></head>
<body>Example output: {{ the_text }}</body>
</html>""",
                                  the_text="alfa")


app.run(port=8100, host='0.0.0.0')