Commit 699db5da by bricioso

fiz login basico

parent 72fb1b68
...@@ -36,17 +36,20 @@ with app.app_context(): ...@@ -36,17 +36,20 @@ with app.app_context():
@app.route('/') @app.route('/')
def login(): def login():
return render_template('login.html') # Como você ainda não tem o login.html, vamos abrir a lista direto
# para você testar se o banco está funcionando!
return redirect(url_for('index'))
@app.route('/catalogo') @app.route('/catalogo')
def index(): def index():
animais = Animal.query.all() animais = Animal.query.all()
# Verifique se seu arquivo se chama index.html ou lista.html # No seu print o arquivo se chama lista.html, não index.html
return render_template('index.html', animais=animais) return render_template('lista.html', animais=animais)
@app.route('/cadastro_animal', methods=['GET', 'POST']) @app.route('/cadastro_animal', methods=['GET', 'POST'])
def cadastro_animal(): def cadastro_animal():
if request.method == 'POST': if request.method == 'POST':
# Pega os dados do formulário do Hiago
novo = Animal( novo = Animal(
nome=request.form['nome'], nome=request.form['nome'],
especie=request.form['especie'], especie=request.form['especie'],
...@@ -72,13 +75,3 @@ def cadastro_pessoa(): ...@@ -72,13 +75,3 @@ def cadastro_pessoa():
db.session.commit() db.session.commit()
return redirect(url_for('index')) return redirect(url_for('index'))
return render_template('cadastro_pessoa.html') return render_template('cadastro_pessoa.html')
\ No newline at end of file
@app.route('/deletar/<int:id>')
def deletar(id):
animal = Animal.query.get(id)
db.session.delete(animal)
db.session.commit()
return redirect(url_for('index'))
if __name__ == "__main__":
app.run(debug=True)
\ No newline at end of file
<h2>Login Fazenda</h2>
<form action="/catalogo">
<input type="text" placeholder="Usuário">
<button type="submit">Entrar no Catálogo</button>
</form>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment