Skip to content
Myr

test.py

This file

Path

scripts/testproj/test.py

37 lines · 674 bytes · Python

Last changed by

Started documentation for blueprintsArmin Ronacherbefore adoptionbfd6776

History of this file

Take it

Started documentation for blueprintsArmin Ronacherbefore adoptionbfd6776

line 1why, one step back
1from flask import Flask, Module, render_template

Added test project I use for testingArmin Ronacherbefore adoption670d2bc

lines 2–5why, one step back
2
34mod = Module(__name__)5mod2 = Module(__name__, 'testmod2')

Allow name to be specified as the first parameter but with an explict name.Armin Ronacherbefore adoptionb4ffa4d

line 6why, one step back
6mod3 = Module(__name__, name='somemod', subdomain='meh')

Added test project I use for testingArmin Ronacherbefore adoption670d2bc

lines 7–20why, one step back
7
89@app.after_request10def after_request(response):11 g.db.close()12 return response131415@mod.route('/')16def index():17 return render_template('test/index.html')181920@mod2.route('/')

Started documentation for blueprintsArmin Ronacherbefore adoptionbfd6776

line 21why, one step back
21def mod2_index():

Added test project I use for testingArmin Ronacherbefore adoption670d2bc

lines 22–24why, one step back
22 return render_template('testmod2/index.html')
2324

Started documentation for blueprintsArmin Ronacherbefore adoptionbfd6776

lines 25–26why, one step back
25@mod3.route('/')
26def mod3_index():

Added test project I use for testingArmin Ronacherbefore adoption670d2bc

line 27why, one step back
27 return render_template('something-else/index.html')

Started documentation for blueprintsArmin Ronacherbefore adoptionbfd6776

lines 28–37why, one step back
28
2930app = Flask(__name__)31app.register_module(mod)32app.register_module(mod2)333435def handle_404(error):36 return 'Testing', 40437app.error_handlers[404] = handle_404