from flask import render_template, request, Blueprint from minibase.database.models import Company, Post from minibase.config import themeMinibase from minibase import db # Declaring a blueprint main = Blueprint('main', __name__) # Redirect from / and also /home routes to the / @main.route("/") @main.route("/home") def home(): # (PAGINATION) Defines the page number that we will start with page = request.args.get('page', 1, type=int) # (POSTS) Query posts usin SQLAlchemy posts = Post.query.order_by(Post.date_posted.asc()).paginate(per_page=2) companies = Company.query.order_by(Company.name.asc()) # (HTML) Renders the template for templates/home.html return render_template('home.html', theme=themeMinibase, posts=posts, companies=companies) @main.route("/about") def about(): return render_template('about.html', theme=themeMinibase, title='About') @main.route("/customer") def customer(): return render_template('customer.html', theme=themeMinibase, title='About') @main.cli.command("initdb") def reset_db(): """Drops and Creates fresh database""" db.drop_all() db.create_all() print("Initialized default DB")