Commit 07c54d6f by bricioso

teste o BD

parents 4f56c48e df75709c
...@@ -8,27 +8,16 @@ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False ...@@ -8,27 +8,16 @@ 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() db.create_all() # Isso cria o arquivo database.db pra você!
# 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)
# 3. ROTAS DE CADASTRO (Ajustadas para os nomes dos seus arquivos) @app.route('/cadastro')
@app.route('/cadastro_animal') def cadastro():
def cadastro_animal(): return render_template('cadastro.html')
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)
......
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