diff options
Diffstat (limited to 'app/main.py')
-rw-r--r-- | app/main.py | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..ac5625f --- /dev/null +++ b/app/main.py @@ -0,0 +1,75 @@ +# -*- mode: python; -*- + +""" +routes.py module +---------------- + +This Python module contains the logic supporting: +1. Navigating between website pages +2. Interpreting user requests to the server +3. Dispatching requested content back to the user + +Python dependencies: +- flask: provides web application features +- forms: provides secure user form submission +- sqlalchemy: provides communication with database on server. + +Personal imports: +These are used to avoid cluttering this file with +placeholder data for posts' content. +""" + + +from flask import ( + Blueprint, + render_template, + send_file, + request, + redirect, + flash, + url_for, + jsonify, + abort, +) +from flask_login import login_required, current_user + + +# from datetime import datetime +# import inspect + +from . import db + +main = Blueprint("main", __name__) + +from .models import Module, User + +modules = [ + "auth", + "customers", + "ferti", + "invoices", + "orders", + "products", +] + + +@main.route("/") +@main.route("/index") +def home(): + """This is our project home page.""" + modules = Module.query.all() + return render_template( + "home.html", user=current_user, project="fapg", modules=modules + ) + + +@main.route("/download-database") +def download_database(): + return send_file("fapg.db") + + +@main.route("/modules") +def all_modules(): + # If unlogged, should present promotional material for available + # modules. + return render_template("modules-promo.html", modules=modules) |