2015-06-16 21:57:44 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from flask import Flask, render_template, redirect, url_for, session
|
|
|
|
from flask_wtf import Form
|
2015-06-17 20:13:55 +02:00
|
|
|
import ldap
|
|
|
|
from redis import Redis
|
2015-06-16 21:57:44 +02:00
|
|
|
from wtforms.fields import PasswordField, SelectField, StringField, SubmitField
|
|
|
|
from wtforms.validators import Required
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
2015-06-17 20:13:55 +02:00
|
|
|
app.config.from_pyfile('index.cfg')
|
2015-06-16 21:57:44 +02:00
|
|
|
app.jinja_env.trim_blocks = True
|
|
|
|
app.jinja_env.lstrip_blocks = True
|
|
|
|
|
2015-06-17 20:13:55 +02:00
|
|
|
rdb = Redis(host='127.0.0.1', password='foobared')
|
|
|
|
|
|
|
|
|
|
|
|
class LoginForm(Form):
|
|
|
|
user = StringField('Username', validators=[Required()])
|
|
|
|
pswd = PasswordField('Password', validators=[Required()])
|
|
|
|
submit = SubmitField('Login')
|
|
|
|
|
2015-06-16 21:57:44 +02:00
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
|
|
|
return render_template('index.html')
|
|
|
|
|
2015-06-17 20:13:55 +02:00
|
|
|
@app.route('/login', methods=['GET', 'POST'])
|
|
|
|
def login():
|
|
|
|
form = LoginForm()
|
|
|
|
if form.validate_on_submit():
|
|
|
|
# TODO implement login with LDAP
|
|
|
|
return redirect(url_for('index'))
|
|
|
|
return render_template('login.html', form=form)
|
2015-06-16 21:57:44 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2015-06-17 20:13:55 +02:00
|
|
|
app.run(host='0.0.0.0', port=5000)
|