Maria Eduarda Afonso

parent 2247515b
...@@ -13,4 +13,20 @@ with app.app_context(): ...@@ -13,4 +13,20 @@ with app.app_context():
@app.route('/') @app.route('/')
def index(): def index():
animais = Animal.query.all() animais = Animal.query.all()
return render_template('index.html', animais=animais) return render_template('index.html', animais=animais)
\ No newline at end of file
# Duda - CADASTRAR
@app.route('/cadstrar', methods=['GET' ' POST'])
def cadastrar():
if request.method =='POST':
novo = Animal(
nome=request.form['nome'],
especie=request.form['especie'],
idade=inte(request.form['idade']),
peso=float(request.form['peso'])
)
db.session.add(novo)
db.session.commit()
return redirect('/')
return
render_template('cadastrar.html')
\ 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