Commit 984d3474 by Mariana Bongiolo
parents 46a22757 1a7fa3cf
......@@ -2,10 +2,15 @@ from flask import Flask, render_template, request, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
import os
app = Flask(__name__)
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
app = Flask(
__name__,
template_folder=os.path.join(ROOT_DIR, 'templates'),
static_folder=os.path.join(ROOT_DIR, 'static')
)
# Caminho do banco
basedir = os.path.abspath(os.path.dirname(__file__))
basedir = ROOT_DIR
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'animais.db')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
......@@ -56,8 +61,8 @@ def index():
animais = Animal.query.all()
return render_template('index.html', animais=animais)
@app.route('/cadastro', methods=['GET', 'POST'])
def cadastro():
@app.route('/cadastrar', methods=['GET', 'POST'])
def cadastrar():
if request.method == 'POST':
try:
novo = Animal(
......@@ -78,7 +83,7 @@ def cadastro():
db.session.rollback()
return f"Erro ao cadastrar: {str(e)}"
return render_template('cadastro.html')
return render_template('cadastrar.html')
@app.route('/delete/<int:id>')
def delete(id):
......
# Relatório de Animais
Nenhum animal cadastrado.
## Marcos
- Espécie: Pitcher
- Idade: 17 anos
- Peso: 67.0 kg
......@@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='static/style.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap" rel="stylesheet">
......@@ -17,7 +17,7 @@
Nome: <input type="text" name="nome" required><br>
Especie: <input type="text" name="especie" required><br>
Idade: <input type="number" name="idade" required><br>
Peso: <input type="number" name="cidade" required><br>
Peso: <input type="number" step="any" name="peso" required><br>
<button type="submit">Salvar</button>
</form>
</body>
......
......@@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{{ url_for('static', filename='static/style.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend:wght@100..900&display=swap" rel="stylesheet">
......
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