from flask import Flask
from flask import Blueprint,render_template,request,url_for
from werkzeug.utils import redirect
import os
from chfi.models import Sensor
from datetime import datetime
from chfi.forms import UserLoginForm
#from smartfarm import app

bp = Blueprint('auth', __name__, url_prefix='/auth')

@bp.route('/login',methods=('GET','POST'))
def login():
	form = UserLoginForm()
	if request.method=='POST':
	#if request.method=='POST' and form.validate_on_submit():
		return redirect(url_for('monitor.sensor'))
	return render_template('auth/login.html',form=form)

@bp.route('/logout')
def logout():
	return render_template('index.html')