comparison 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
comparison
equal deleted inserted replaced
2:e0061735c327 3:79fc37fe85a6
1 from flask import Module 1 #!/usr/bin/python
2 from mfrontend import db 2 # -*- coding: utf-8 -*-
3
4 from flask import Module, render_template, request, url_for
5 from mfrontend import db, utils
3 frontend = Module(__name__) 6 frontend = Module(__name__)
4 7
5 @frontend.route('/') 8 @frontend.route('/')
6 def index(): 9 def index():
7 lol = db.query_db('select id, username, password from users') 10 lol = db.query_db('select id, username, password from users')
8 return lol[0]['username'] 11 return lol[0]['username']
12
13 @frontend.route('/login', methods=['GET', 'POST'])
14 def login():
15 if request.method == 'POST':
16 return "Uname: {0}<br />Passwd: {1}<br />Hashpwd: {2}".format(
17 request.form['username'],
18 request.form['password'],
19 utils.hashPassword(request.form['password']))
20 return render_template('login.html')
21