Guides, Source Code, Syntax
May, 24, 2024
Reports, Source Code, Syntax on my personal Computer Science research
Project Interlink
Joe Corso
01-21-2024
It takes too long to manually write every form and report you need for a database
Automate the generation of forms, reports, navigation, and access controls
Interlink reduces time-to-deploy for data-heavy applications by abstracting away routine form and report logic. It streamlines software operations and automates flask appications at the infrastructure level.
NA
By consolidating templating, access control, and DB-driven form/report logic, Interlink provides a minimalist yet powerful platform that complements Flask’s ecosystem. Interlink is a modular, Flask-based Python framework designed to accelerate development of data-driven web applications. Interlink automates the generation of forms, reports, navigation, and access control based on MySQL database schemas. The system offers a low-code solution for rapidly building internal tools and administrative dashboards without sacrificing control or customizability.
formulator: Generates HTML forms and
reports directly from database tables.templeton: Provides a templating layer
and ready-to-use Flask Blueprints for common views.safeHaven: Offers pluggable security
decorators (@requireLogin, @honeypot, etc.) to
protect routes.toolkit: A utility module for DB
connections, route registration, and view generation automation.Interlink is a practical, extensible framework that embodies the PADS philosophy: less boilerplate, more velocity. It empowers developers to move fast, stay organized, and build interfaces that just work — all while keeping security and modularity at the forefront.
Each module can be loaded as a Flask Blueprint, allowing independent development and integration. Navigation, view registration, and auth middleware are initialized at the application level.
/interlink/src/interlink
├── formulator
│ ├── __init__.py
│ └── logic.py
├── __init__.py
├── __main__.py
├── safeHaven
│ └── __init__.py
├── templeton
│ ├── __init__.py
│ ├── templates
│ │ ├── 404.html
│ │ ├── 500.html
│ │ ├── admin.html
│ │ ├── copyright.html
│ │ ├── data.html
│ │ ├── forms.html
│ │ ├── guide
│ │ │ └── index.html
│ │ ├── login.html
│ │ ├── nav.html
│ │ ├── reports.html
│ │ ├── template.html
│ │ └── templeton.html
│ └── views.py
└── toolkit
└── __init__.py
┌─────────────┐ ┌──────────────┐
│ formulator │───▶│ templeton │
└─────────────┘ └──────────────┘
│ │
▼ ▼
┌─────────────┐ ┌──────────────┐
│ safeHaven │ │ toolkit │
└─────────────┘ └──────────────┘
A minimal UI approach is taken by default, but templates are overrideable using Jinja2 template inheritance. Menus and layouts are dynamically generated based on the database schema and user permissions.
Interlink is a Flask-compatible backend library suite that generates form interfaces, reporting views, and access-controlled pages based on MySQL table schemas. It follows a plugin architecture with four core modules: formulator, templeton, safeHaven, and toolkit.
Clearly define the technical challenge or need that this report addresses.
Describe the processes, tools, and technologies used to address the
problem.
Include diagrams, charts, or pseudocode if applicable.
interlink.formulator
interlink.templeton
interlink.safeHaven
interlink.toolkit
What it lacks for in developers, it makes up for in development.
“Running record of steps, discoveries, and next actions.”
Cleaned up a lot of the files to make it resemble a MVC concept a little better.
Started working on a CLI version. I hope it could be useful for throwing up a report in the terminal real quick; as opposed to starting a server, etc. I think in the future, the output could be piped to a separate text file that could be printed or maybe incorporated in an LLM. I worked on it a few weeks ago, and did write the research so this is in hind sight, and I don’t remember the steps.
I was getting tired of trying to figure out how to set up this lib
each time I needed to work on it, so I created a few new directories to
just put everything I needed into the proper directories.
tests for tests, scripts for setup and
runtime, examples to build a working demo. Also a
tree.txt file in docs.
$ mkdir {tests,examples,scripts,docs} $ mkdir tests/dev
$ python -m venv tests/dev/venv
$ . tests/dev/venv/bin/activate
$ python -m pip install --upgrade pip
$ python -m pip install -e ~/code/interlinkBuild Flask project (I just copied from an old setup using interlink already).
Add src/interlink/__main__.py file. So that
interlink can be run from the command line
(i.e. python -m interlink)
Install click, add as a dependancy to pyproject.toml
file.
$ python -m pip install click
-> pyproject.toml
dependencies = [
"flask>=2.3",
"mysql>=0.0.3",
"mysqlclient>=2.2.7",
"mysql-connector>=2.2.9",
"click>=8.3.1"
]Refactoring some code, so it makes more sense. I noticed that the description in the Generator class was the same as the DB class.
getFormData() into the class
formulator.Generator.generateForm()getDatabase(),
getTables(), getEnumData(),
getMetadata() to a new class DataHandlerGenerator class to make more
sense.(Continue adding sections for each workday or session)
Interlink is a modular Python/Flask library suite that automates the generation of CRUD forms, tabular reports, and navigation menus from MySQL database schemas. Its purpose is to drastically reduce development time for database-driven web applications while ensuring consistent design, maintainable code, and built-in security.
formulator, templeton,
safeHaven, and toolkit.INFORMATION_SCHEMA.safeHaven.toolkit.templeton.safeHaven).env
filepytest.Template generated by ChatGPT
Documentation generated by PADDOCS
Compendium section: 10-docs
Title: Project Interlink
Author: Joe Corso
Created: 2024-01-21
Updated: 2025-07-02
Tags: interlink, flask, forms, report, mariadb
Status: [ Draft / Final / Reviewed ]
Template:
- 00-project-proposal.md
- 01-project-overview.md
- 02-design-report.md
- 03-technical-report.md
- 04-research-log.md
- 05-final-report.md
License: “All Rights Reserved”
Schema: technical
Version: 0.1.1
Branding: Operation Mindmap
version
1.2.1
author
Joe Corso
date
01-21-2024
updated
02-22-2026
copyright
Copyright 2024 Joe Corso
license
MIT License
pads.email.address@gmail.com
status
Production
description
Flask Generator for Forms, Reports, URLs and Templates.
Flask Generator for Forms, Reports, URLs and templates.
This is a collection of libraries written to work in Python’s flask
framework. It will generate a form and report for any table in a
database. It will also create the urls, and the navigation bar. You can
customize your website by generating your own instance of the API; or
you can register the
Blueprint(e.g. app.register_blueprint(templetonBP)), which has its own
set of templates.
So essentially, if you create a database for a library like in all
tutorials and you need a form template and a report template, it will
generate the form or report from the table in the database, and fill in
the details in the template. To render the page in the browser just type
in the url which corresponds to the table name, or make a navigation bar
to generate the links for you.
Examples:
Setting up interlink is very easy. It depends on mysql-connector, and flask. Which will be downloaded automatically when installed. Let’s say we want to make a blog, and we have a database named “blog” with a table named “manifest”. This documentation is not in the same scope of writing SQL, we will assume you’ve set up your blog any way you want. That’s the beauty of interlink, it doesn’t matter.
$ python -m venv path/to/venv/my_env
$ . path/to/venv/my_env/bin/activate
$ python -m pip install git+https://github.com/padsRepo/interlink.git__init__.py
file for easier reading. __init__.py
import os
from flask import Flask, Blueprint, render_template, url_for
from views import viewsBP
KEY = os.urandom(16)
os.environ['SECRET_KEY'] = str(KEY) # REQUIRED
os.environ['DB_USER'] = '<username>' # REQUIRED
os.environ['DB_PASS'] = '<password>' # REQUIRED
os.environ['BASE_DIR'] = os.path.dirname(__file__)
os.environ['LOG_DIR'] = os.environ.get('BASE_DIR') + '/log'
os.environ['whitelist'] = '["127.0.0.1", "192.168.0.37"]' # REQUIRED
os.environ['blacklist'] = '["71.71.71.71"]' # REQUIRED
app = Flask(__name__)
app.config.from_mapping(SECRET_KEY=os.environ.get('SECRET_KEY'))
app.config['UPLOAD_FOLDER'] = 'repo/'
from interlink import *
app.register_blueprint(viewsBP) # Your views.py file
app.register_blueprint(templetonBP) # Add to use interlinks templating engine
app.register_error_handler(404, url_not_found) # From the templeton lib
app.register_error_handler(500, internal_error) # From the templeton lib
if debug == False:
app.run(debug=True, host='0.0.0.0', port='8000')
templetonBP has all the templates you need. There
is a default admin, forms, reports, blog, login, index page, and its own
documentation. It helps to load the templetonBP
after your own library. If you have variables set
outside the scope of the __init__.py file, interlink will
not find them. 127.0.0.1:8000/admin/blog
127.0.0.1:8000/forms/blog/manifest
127.0.0.1:8000/reports/blog/manifest
127.0.0.1:8000/blog/manifest # for the blog you want everyone to see
127.0.0.1:8000/admin/blog
127.0.0.1:8000/copyright/
127.0.0.1:8000/404/
127.0.0.1:8000/500/
127.0.0.1:8000/docs/<page>/ # the docs page for this library.
127.0.0.1:8000/loginRequired/
127.0.0.1:8000/login/
127.0.0.1:8000/register/
127.0.0.1:8000/index/| Modules | Description |
|---|---|
| formulator | Form and Report Generator |
| templeton | Template Generator |
| safeHaven | Security Guard |
| toolkit | Misc Tools |
| Classes | Description |
|---|---|
| Generator | Object method used to query database |
| DB | Object method used to connect and close connection to database |
| Tempulation | Custom Views |
| Functions | Description |
|---|---|
| tempulator | templates |
| honeypot | distraction |
| backdoor | entry way |
| login | check user |
| site_map | site map for SEO |
| url_not_found | 404 Error |
| internal_error | 500 Error |
| templetonBP | Templeton Templates |
This is the Toolkit Module. It contains classes and functions that are reuseable across the entire library.
Get the directory path of the project
Generate a URL for each view that does not have a GET or POST method.
The formulator is used as the SQL engine to gather the data from the database to populate the template.
The formulator module makes use of the Generator()
object, to connect to the database, find the proper table, query the
results, and return a value that can be passed into an html template. It
is the main module behind the Interlink library. It acts as the SQL
engine, to generate a return value, that can be manipulated to the
developers needs. It’s main dependancy is the toolkit.DB()
object for connection to a database. Make sure you have the proper
environment variables set to ensure proper connection. If the project
does not fit into the templetonBP this module will assist
in automating redundant SQL statements, form, and report development,
and navigation menus which need to sort administration, from users, from
bad actors. It can be used along side other modules in the library as
well as imported directly into your own project.
Let’s say you dont like templetons blog template and you want to use
your own blog template. Use the formulator.Generator to
make a query of your blog table from your SQL database. Create a
variable from it, and then using Jinja’s Templating Engine with Flask,
we can manipulate the variable in an html template anyway we want.
In your views.py file you only need two specific views that will
generate every form, and report respectively. In the
index() function you will see the nav variable set to
generateNav(). This generates the navigation bar for you.
It can be used in the template to build the navigation menu. If you’re
familiar with flask’s Blueprints, then this should look pretty simple.
If not, check out the flask docs, it’s pretty cool.
Basically, make a route for a reports url and a route for a forms url
so that the computer doesn’t confuse the two. For your route you need to
define a parameter for your database, and table. This is just to pass
into the generateReport() or generateForm()
functions which is used to find the table, and create the form or
report. The report needs 4 parameters(One for the column names of the
table, one for the data in the table, a title, and a generic error) and
the form needs 3(One to generate the forms, a title, and a generic
error). The generateNav() doesn’t need a parameter, but it
searches for the database you set to your
Generator.__init__(). Make sure to register the views:
__init__.py
from views import viewsBP
app.regist_blueprint(viewsBP) views.py
from flask import Blueprint, render_template
import interlink as i
viewsBP = Blueprint('/', __name__, url-prefix='/')
@viewsBP.route(/)
def index():
gen = i.Generator('DB', 'DB_USER', 'DB_PASS')
nav = gen.generateNav()
return render_template('index.html', nav=nav)
@viewsBP.route('/<db>/<table>')
def blog(db, table):
gen = Generator(db, 'DB_USER', 'DB_PASS')
content = gen.generateQuery(table)
return render_template('template.html', content=content)
@viewsBP.route('/reports/<db>/<table>')
def generateReport(db, table):
gen = i.Generator(db, 'DB_USER', 'DB_PASS')
colName, colRow, error, title = gen.generateReport(table)
return render_template('reports.html', colName=colName, colRow=colRow, error=error, title=title)
@viewsBP.route('/forms/<db>/<table>', methods=['GET', 'POST'])
def generateForm(db, table):
gen = i.Generator(db, 'DB_USER', 'DB_PASS')
error, form, title = gen.generateForm(table)
return render_template('forms.html', form=form, error=error, title=title)
@viewsBP.route('/admin/<db>')
def admin(db):
nav = Generator(db, 'DB_USER', 'DB_PASS').generateNav()
return render_template('admin.html', nav=nav, db=db, title=db)Make a template for your Forms:
forms.html
{% extends 'base.html' %}
{% block description %}{% endblock %}
{% block keywords %}{% endblock %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<article class="index">
<section class="col-6 col-s-6 col-m-6">
<fieldset class="form">
<label>{{ error }}</label>
<form method="POST">
{% for f in form %}
<label for="{{ f[0] }}">{{ f[0] }}</label>
<input type="text" name="{{ f[0] }}">
{% endfor %}
<input type="submit" value="submit">
</form>
</fieldset>
</section>
</article>
{% endblock %}
Make a template for your reports:
reports.html
{% extends 'base.html' %}
{% block description %}{% endblock %}
{% block keywords %}{% endblock %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<article class="col-12 col-s-12 col-m-12">
<h1>{{ title }} Report</h1>
{{ error }}
<table class="data">
<tr>
{% for c in colName %}
<th>{{ c[0] }}</th>
{% endfor %}
</tr>
{% for row in colRow %}
<tr>
{% for c in row %}
<td>{{ c }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
</article>
{% endblock %}
Finally, make a navigation menu for it all. The formulator filters “timestamp”, “pri”, “uni”, “mul”, “updated”, and “q”.
base.html
<nav class="pc mobile">
<a href="{{ url_for('/.index') }}">Index</a>
<div class="dropdown">
<span>Reports</span>
<div class="dropdownContent">
{% for p in nav %}
<a href="{{ url_for('templeton.generateReport', db='{}'.format(db), page='{}'.format(p[0])) }}">{{ p[0] }}</a>
{% endfor %}
</div>
</div>
<div class="dropdown">
<span>Forms</span>
<div class="dropdownContent">
{% for p in nav %}
<a href="{{ url_for('templeton.generateForm', db='{}'.format(db), page='{}'.format(p[0])) }}">{{ p[0] }}</a>
{% endfor %}
</div>
</div>
</nav>
That’s it! So if you have a DB with tables named books, authors, planets, solarSystems….etc. Just type in the url for the table name. For example:
https://www.website.com/reports/library/authors
https://www.website.com/reports/library/books
https://www.website.com/forms/library/authors
https://www.website.com/forms/library/books
OR
https://www.website.com/reports/science/solarSystems
https://www.website.com/reports/science/planets
https://www.website.com/forms/science/solarSystems
https://www.website.com/forms/science/planets
The DB class is designed to facilitate operations on databases using MariaDB. It enables you to establish connections to your database with credentials that possess appropriate permissions. Ensure you close the connection after completing your operations to avoid potential resource leaks.
| Args | Description |
|---|---|
| db (str) | Database Name, Must be an ENV VAR |
| user (str) | User Name, Must be an ENV VAR |
| password (str) | Password, Must be an ENV VAR |
| Returns | Description |
|---|---|
| mydb (str) | Connection to Database |
Example:
os.eviron['db'] = 'library'
os.eviron['user'] = 'franklin'
os.eviron['password'] = 'aklsdjhashdfsajkdfh'
@viewsBP.route('/report/<db>/<page>')
def myFuntion(db, user, password):
db_conn = DB(db, user, password).connect()
cursor = db_conn.cursor(buffered=True)
cursor.execute(f"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='{db}'; ")
sql = cursor.fetchone()
db_conn.close()
return sqlInitialize the database object
None
None
Used to make a connection to MariaDB
Used to close a connection to MariaDB
The DataHandler class is designed to manage various data operations related to databases, including fetching database and table names, retrieving enumerated list data, and obtaining metadata.
| Args | Description |
|---|---|
| db_name (str) | The name of the database. |
| user (str) | The username for the database connection. |
| password (str) | The password for the database connection. |
None
Get Database Names which the user has access to.
| Returns | Description |
|---|---|
| sql(list) | A list of tuples containing database names |
Get Table Names from a specific Database which the user has access to.
| Returns | Description |
|---|---|
| sql(list) | A list of tuples containing table names. |
Retrieve HTML options for enumerated lists from a given table.
| Args | Description |
|---|---|
| table (str) | The name of the table. |
| Returns | Description |
|---|---|
| html(str) | An HTML string representing the select element. |
Obtain metadata related to foreign keys in a specified table.
| Args | Description |
|---|---|
| table (str) | The name of the table. |
| Returns | Description |
|---|---|
| html(str) | An HTML string representing the select element. |
The generator is the module used to generate your forms, reports, queries, and anything DB related. It wraps the core functionality of the modeule into a reusable Class Object which you can use to recall a connection or query to a specifc database and table. In practice, the developer would not have to write the boilpate code needed to connect, query, and close connection to the database. By leveraging the concept of OOP, the intent is to mitigate, and slow down DDOS attacks, by preventing the end user from creating multiple concurrent conections to any given website.
| Args | Description |
|---|---|
| db (str) | Database Name, Must be an ENV VAR |
| user (str) | User Name, Must be an ENV VAR |
| password (str) | Password, Must be an ENV VAR |
Example:
@templetonBP.route('/blog/')
@honeypot
@backdoor
def blog():
gen = Generator('blog', 'DB_USER', 'DB_PASS')
colName, colRow, error, title = gen.generateReport('blog')
return render_template('blog.html', colName=colName, colRow=colRow, error=error, title=title)Initialize the Generator object. This would, in theory, create a new object in the session which the server could point back to.
None
None
Generate a form using table name to populate the
form.html template.
TODO:
- Find better terms for the functions and values of data and
enumList
| Args | Description |
|---|---|
| table (str) | Name of table within database |
| Returns | Description |
|---|---|
| error (str) | 200 404 500 |
| form (str) | Data used to populate template |
| data (str) | Finds metadata and creates a dropdown menu |
| enumList(str) | Finds any enumerations in SQL and creates a dropdown menu |
| title (str) | Name of db given from init |
Example:
@templetonBP.route('/forms/<db>/<page>', methods=['GET', 'POST'])
@backdoor
@login
@honeypot
def generateForm(db, page):
gen = Generator(db, 'DB_USER', 'DB_PASS')
error, form, data, enumList, title = gen.generateForm(page)
return wrapper('forms.html', form=form, error=error, title=title, data=data, enumList=enumList)Generate a report using table name to populate the
report.html template.
| Args | Description |
|---|---|
| table (str) | Name of table within database |
| Returns | Description |
|---|---|
| colName (str) | Name of each column in the table |
| colRow (str) | Data within each row of the table |
| error (str) | 200 404 500 |
| title (str) | Name of table given from init |
Example:
@templetonBP.route('/reports/<db>/<page>')
@backdoor
@login
@honeypot
def generateReport(db, page):
gen = Generator(db, 'DB_USER', 'DB_PASS')
colName, colRow, error, title = gen.generateReport(page)
return wrapper('reports.html', colName=colName, colRow=colRow, error=error, title=title)Run a custom SELECT statement to see the results.
TODO:
- Add *args to select different columns.
| Args | Description |
|---|---|
| table (str) | Table name to query |
| select (str) | List of column names to filter. List a traditional SQL Select Statement. |
| Returns | Description |
|---|---|
| sql (str) | Index of the data for each column in a record |
Generate a URL for each table in a db, which the user has access. This is useful within an Admin Page, to generate a url for each form or report of the table.
Example:
-> views.py
@templetonBP.route('/admin/<db>')
@backdoor
@login
@honeypot
def admin(db):
nav = Generator(db, 'DB_USER', 'DB_PASS').generateNav()
return wrapper('admin.html', nav=nav, db=db, title=db)-> base.html
<div class="adminNav col-5">
<h2>Reports:</h2>
{% for p in nav %}
<a href="{{ url_for('templeton.generateReport', db='{}'.format(db), page='{}'.format(p[0])) }}">{{ p[0] }}</a><br>
{% endfor %}
</div>
<div class="adminNav col-5">
<h2>Forms:</h2>
{% for p in nav %}
<a href="{{ url_for('templeton.generateForm', db='{}'.format(db), page='{}'.format(p[0])) }}">{{ p[0] }}</a><br>
{% endfor %}
</div>
Generate a URL for each db, which the user has
access. This is useful to generate a navigation bar in a
base.html file, to access each database. Which would lead
you to an admin page to generate a url for each table within the
database.
Example:
-> views.py
@templetonBP.route('/dashboard/')
def dashboard():
database = Generator('', 'DB_USER', 'DB_PASS').generateURL()
return render_template('data.html', database=database)-> base.html
{% for d in database %}
<li><a href="{{ url_for('templeton.admin', db='{}'.format(d[0])) }}" title="{{ d[0] }} Panel"><img src="{{ url_for('templeton.static', filename='/img/icons/ai-settings2-t.png') }}"><span>{{ d[0] }}</span></a></li>
{% endfor %}
Safe Haven is like the security team for the president. Always lurking in the shadows, ready to defend your best interest. Since these are decorators they’re easy to use.
All you have to do is add the appropriate decorator to each page that you want to add the functionality to. Here’s a simple index page, that I want really locked down.
@viewsBP.route('/')
@backdoor
@honeypot
@login
def index():
return render_template('index.html')
And there’s nothing more to it then that. Safe Haven checks that the person connecting passes, and if not redirects them to the appropriate page. If you’re using templeton’s Blueprints it will redirect to its login screen, and everything works seamlessly.
Python decorator you can use as a honeypot. Any IP Adress that is black listed will be redirected to a login page that logs the username and password they attempt to use.
Python decorator you can use as a backdoor. Any page which has this decorator will give IP Address’ on the whitelist full access to the page.
Python decorator you can use to check if a user is logged in. If not, they will be redirected to a login page from where they can log in.
This module is used to access Interlink from the CLI.
Test Model
None
None
CLI Mode
Generate a report for table
This script prints some colors. It will also automatically remove all ANSI styles if data is piped into a file.
Give it a try!
Templeton is like the butler used to fetch the templates, fill in the proper parameters, and serve it to you on a silver platter. Templeton builds the skeleton website for you. All you have to do is type in the proper URL, or generate the navigation bar.
The easiest way to use templeton is to register its Blueprint’s in
your app. There are three; 404, 500, and
templetonBP.
-> __init__.py
from interlink.templeton.views import templetonBP
app.register_blueprint(templetonBP)
app.register_error_handler(404, url_not_found)
app.register_error_handler(500, internal_error)The templetonBP has a default set of templates you can
use to have a full website deployed. The URL’s which Templeton uses are
as follows:
127.0.0.1:8000/admin/<db>
127.0.0.1:8000/forms/<db>/<table>
127.0.0.1:8000/reports/<db>/<table>
127.0.0.1:8000/<db>/<table> # for the blog you want everyone to see
127.0.0.1:8000/admin/<db>
127.0.0.1:8000/copyright/
127.0.0.1:8000/404/
127.0.0.1:8000/500/
127.0.0.1:8000/docs/<page>/ # the docs page for this library.
127.0.0.1:8000/loginRequired/
127.0.0.1:8000/login/
127.0.0.1:8000/register/
127.0.0.1:8000/index/Whatever the name of the database, type the name into the db parameter. Whatever the name of the table, type the name into the table parameter. It will generate a generic template for you.
The Tempulations are used to build a new url rule, based on the developers needs.
[!NOTE]
Remember that with templeton’s tempulator, the generic templates are only coming frominterlink.templeton.views. If you want to change where it’s coming from you can use templeton’s Tempulation, and create a new url loader function.
Templeton also comes equiped with a tempulator, which runs off of Tempulations. The tempulator is basically just Flask Lazy Loading URL’s in a wrapper. This feature is used to route Templetons templates to a URL, but does not have an endpoint(e.g. does not load by default). It is used to add extra templates to the app, if needed, without added overhead to the base project. For example, if you make a blog, you should be able to build a blog without also loading the catalog from an ecommerce site into memory, and vice versa. By using the tempulator, you can load a blog without a journal, or an ecommerce site without a repository, or a snosberry without an everlasting gobbstopper. You can also use the tempulator to load one endpoint before the other. If you like templetons catalog view, and you’re an ecommerce site you may want to load that as your index page. This would achieve those results. If you like the admin page, but need it rerouted to another URL, you would use templulator.
Generate a new url_rule from any view within your project. This is used if you would like to map out url rules for each of your own endpoints.
Examples:
# Use the Tempulation's to create a new URL:
app.add_url_rule('/dash', view_func=Tempulation('interlink.templeton.views.dashboard'))
# make a new tempulator
def myNewTempulator(import_name, url_rules=[], **options):
view = Tempulation(f"@{app_name@}.@{import_name@}")
for url_rule in url_rules:
app.add_url_rule(url_rule, view_func=view, **options)
Initialize the Tempulation object. This will hold the variable for the new url_rule.
| Args | Description |
|---|---|
| object (str) | Endpoint for new view |
None
None
The tempulator is used to add extra templates to the app, if needed, without added overhead to the base project. For example, if you make a blog, you should be able to build a blog without also loading the catalog from an ecommerce site into memory, and vice versa. By using the tempulator, you can load a blog without a journal, or a ecommerce site without a repository, or a snosberry without an everlasting gobbstopper. You can also use the tempulator to load one endpoint before the other. If you like templetons catalog view, and you’re an ecommerce site you may want to load that as your index page. This would achieve those results.
--> views.py
# load templetons catalog view as the index view
@templetonBP.route('/')
@login
def catalog():
return tempulator("views.catalog", ['/catalog'], app = app)
# add a single route to the catalog view
tempulator('views.catalog', ['/catalog'], app = app)
# add two routes to a single function endpoint
url_rules = ['/catalog/','/catalog/<item>']
tempulator('views.catalog', url_rules, app = app)
Used to wrap all the web pages in default params.
TODO:
- Make a decorator.
| Args | Description |
|---|---|
| page(str) | Passes the var to render_template |
| kwargs(dict) | Added settings to the webpage. |