git.fiddlerwoaroof.com
Raw Blame History
from flask import Flask, url_for, redirect, request
import mako.template as mako
import logging

app = Flask(__name__)

articles = [
    dict(
        articleid = 0,
        title = 'The title',
        body = 'The Body'*50,
        comments = []
    )
] * 12


@app.route("/")
def main(idx=0):
    article = articles[idx]
    print('pre-template')
    template = mako.Template(open('main.mako').read())
    print('pre-render')
    result = template.render(maintitle="test", **article)
    print('rendered')
    return result

@app.route("/addcomment", methods=['POST'])
def addcomment():
    print(request.form['articleid'], request.form['comment'])
    return redirect(url_for('main'))

app.run('172.16.1.2', debug=True)