Commit 4f56c48e by bricioso

atualizei o banco de dados novamente

parent f035a5e6
...@@ -8,16 +8,27 @@ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False ...@@ -8,16 +8,27 @@ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db.init_app(app) db.init_app(app)
with app.app_context(): with app.app_context():
db.create_all() # Isso cria o arquivo database.db pra você! db.create_all()
# 1. ROTA DE LOGIN (Agora o site começa aqui!)
@app.route('/') @app.route('/')
def login():
return render_template('login.html')
# 2. ROTA DO CATÁLOGO (Onde as pessoas veem as ofertas)
@app.route('/catalogo')
def index(): def index():
animais = Animal.query.all() animais = Animal.query.all()
return render_template('lista.html', animais=animais) return render_template('lista.html', animais=animais)
@app.route('/cadastro') # 3. ROTAS DE CADASTRO (Ajustadas para os nomes dos seus arquivos)
def cadastro(): @app.route('/cadastro_animal')
return render_template('cadastro.html') def cadastro_animal():
return render_template('cadastro_animal.html')
@app.route('/cadastro_pessoa')
def cadastro_pessoa():
return render_template('cadastro_pessoa.html')
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True) app.run(debug=True)
\ No newline at end of file
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Animal(db.Model): class Animal(db.Model):
__tablename__ = 'animais' __tablename__ = 'animais'
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
nome = db.Column(db.String(100), nullable=False) nome = db.Column(db.String(100), nullable=False)
especie = db.Column(db.String(50), nullable=False) especie = db.Column(db.String(50), nullable=False) # Ex: Suíno
idade = db.Column(db.Integer, nullable=False) preco = db.Column(db.Float, nullable=False) # Preço de venda
fazenda = db.Column(db.String(100), nullable=False) # Quem está vendendo
peso = db.Column(db.Float, nullable=False) peso = db.Column(db.Float, nullable=False)
\ 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