# main.py
|
|
|
|
from flask import Blueprint, render_template, redirect, url_for
|
|
|
|
from flask_login import login_required, current_user
|
|
from .models import Carburante, db
|
|
|
|
|
|
main = Blueprint('main', __name__)
|
|
|
|
@main.route('/')
|
|
def index():
|
|
return render_template('index.html')
|
|
|
|
@main.route('/profile')
|
|
@login_required
|
|
def profile():
|
|
return render_template('profile.html', name=current_user.name)
|
|
|
|
@main.route('/listado')
|
|
def listado():
|
|
|
|
|
|
repostaje = db.get_or_404(Carburante, 1)
|
|
|
|
# check if user actually exists
|
|
# take the user supplied password, hash it, and compare it to the hashed password in database
|
|
if not repostaje :
|
|
print("no encuentro nada")
|
|
return redirect(url_for('main.profile')) # if user doesn't exist or password is wrong, reload the page
|
|
|
|
print("Datos: ", repostaje)
|
|
# if the above check passes, then we know the user has the right credentials
|
|
return redirect(url_for('main.listado'))
|