diff frontend/mfrontend/views/frontend.py @ 3:79fc37fe85a6

Zabawy z Flaskiem ciąg dalszy, zaczyna to jakoś wyglądać
author michalr
date Tue, 22 Feb 2011 19:25:10 +0000
parents c3fb1e9fc1f7
children cf786ee26a22
line wrap: on
line diff
--- a/frontend/mfrontend/views/frontend.py	Tue Feb 22 18:37:32 2011 +0000
+++ b/frontend/mfrontend/views/frontend.py	Tue Feb 22 19:25:10 2011 +0000
@@ -1,8 +1,21 @@
-from flask import Module
-from mfrontend import db
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+from flask import Module, render_template, request, url_for
+from mfrontend import db, utils
 frontend = Module(__name__)
 
 @frontend.route('/')
 def index():
     lol = db.query_db('select id, username, password from users')
     return lol[0]['username']
+
+@frontend.route('/login', methods=['GET', 'POST'])
+def login():
+    if request.method == 'POST':
+        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')
+