Mercurial > kraina_muminkow
comparison frontend/mfrontend/views/frontend.py @ 5:3ba60dfc1d64
Dodałem prosty instalator aplikacji tworzący bazę danych ze schematu
author | Michał Rudowicz <michal.rudowicz@fl9.eu> |
---|---|
date | Sun, 27 Feb 2011 09:33:03 +0100 |
parents | cf786ee26a22 |
children | 27d63cac76ac |
comparison
equal
deleted
inserted
replaced
4:cf786ee26a22 | 5:3ba60dfc1d64 |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 3 |
4 from flask import Module, render_template, request, url_for, escape, session, redirect, flash | 4 from flask import Module, render_template, request, url_for |
5 from flask import escape, session, redirect, flash, abort | |
5 from mfrontend import db, utils | 6 from mfrontend import db, utils |
6 frontend = Module(__name__) | 7 frontend = Module(__name__) |
7 | 8 |
8 @frontend.route('/') | 9 @frontend.route('/') |
9 def index(): | 10 def index(): |
10 return render_template('hello.html') | 11 return render_template('hello.html') |
12 | |
13 @frontend.route('/install') | |
14 def install(): | |
15 """Instaluje aplikację, tworząc pustą bazę danych | |
16 według schematu. | |
17 """ | |
18 if db.init_db(): | |
19 return render_template('install_ok.html') | |
20 else: | |
21 abort(404) | |
11 | 22 |
12 @frontend.route('/login', methods=['GET', 'POST']) | 23 @frontend.route('/login', methods=['GET', 'POST']) |
13 def login(): | 24 def login(): |
14 if request.method == 'POST': | 25 if request.method == 'POST': |
15 if db.user_can_login(request.form['username'], | 26 if db.user_can_login(request.form['username'], |