Commit 5b6cbd98 by Beatryz Chagas

beatryz

parent ce4f9f3e
......@@ -9,27 +9,8 @@ db.init_app(app)
with app.app_context():
db.create_all()
# LISTAR (página inicial)
# BEATRYZ — LISTAR
@app.route('/')
def index():
animais = Animal.query.all()
return render_template('index.html', animais=animais)
\ No newline at end of file
# EDITAR (Nicoly)
@app.route('/editar/<int:id>', methods=['GET', 'POST'])
def editar(id):
animal = Animal.query.get(id)
if request.method == 'POST':
animal.nome = request.form['nome']
animal.especie = request.form['especie']
animal.idade = int(request.form['idade'])
animal.peso = float(request.form['peso'])
db.session.commit()
return redirect('/')
return render_template('editar.html', animal=animal)
if __name__ == '__main__':
app.run(debug=True)
\ 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