Mercurial > kraina_muminkow
view frontend/mfrontend/views/frontend.py @ 4:cf786ee26a22
MOŻNA SIĘ LOGOWAĆ I WYLOGOWAĆ jestem wspaniały
author | michalr |
---|---|
date | Tue, 22 Feb 2011 20:38:51 +0000 |
parents | 79fc37fe85a6 |
children | 3ba60dfc1d64 |
line wrap: on
line source
#!/usr/bin/python # -*- coding: utf-8 -*- from flask import Module, render_template, request, url_for, escape, session, redirect, flash from mfrontend import db, utils frontend = Module(__name__) @frontend.route('/') def index(): return render_template('hello.html') @frontend.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': if db.user_can_login(request.form['username'], request.form['password']) : session['logged_in'] = True session['logged_user'] = request.form['username'] flash('Zalogowano') return redirect(url_for('index')) return "Uname: {0}<br />Passwd: {1}<br />Hashpwd: {2}".format( request.form['username'], request.form['password'], utils.hashPassword(request.form['password'])) return render_template('login.html') @frontend.route('/logout') def logout(): """Funkcja powoduje wyczyszczenie sesji użytkownika, a w efekcie wylogowanie z systemu. """ session.clear() flash('Wylogowano') return redirect(url_for('index'))