summaryrefslogtreecommitdiff
path: root/app/main.py
diff options
context:
space:
mode:
authorMarius Peter <marius.peter@tutanota.com>2022-05-15 13:17:35 +0200
committerMarius Peter <marius.peter@tutanota.com>2022-05-15 13:17:35 +0200
commite084f90c19e779592f6e3f14eb8f70a7287f0dad (patch)
tree1215177356105452c39a916fd050f79c9721f523 /app/main.py
parent1dad22d3e45d6506c8624e3a7111240fcc4ab786 (diff)
Modularization.
Diffstat (limited to 'app/main.py')
-rw-r--r--app/main.py75
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)
Copyright 2019--2024 Marius PETER