commit 12e943f65c784074d11b3dac5a8afb50f7d275a9 Author: Jonathan Carter Date: Sat Mar 30 22:37:58 2024 +0200 Initial layout diff --git a/src/applets/main/__init__.py b/src/applets/main/__init__.py new file mode 100644 index 0000000..90d17c0 --- /dev/null +++ b/src/applets/main/__init__.py @@ -0,0 +1,6 @@ +from flask import Blueprint + +bp = Blueprint('main', __name__) + +from applets.main import routes + diff --git a/src/applets/main/__pycache__/__init__.cpython-311.pyc b/src/applets/main/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..ed1a5d5 Binary files /dev/null and b/src/applets/main/__pycache__/__init__.cpython-311.pyc differ diff --git a/src/applets/main/__pycache__/routes.cpython-311.pyc b/src/applets/main/__pycache__/routes.cpython-311.pyc new file mode 100644 index 0000000..8fa8c20 Binary files /dev/null and b/src/applets/main/__pycache__/routes.cpython-311.pyc differ diff --git a/src/applets/main/routes.py b/src/applets/main/routes.py new file mode 100644 index 0000000..5cc9f5a --- /dev/null +++ b/src/applets/main/routes.py @@ -0,0 +1,21 @@ +from applets.main import bp + + +@bp.route('/') +def index(): + """ + The page you'd get if you access the root of + this app in a browser. + """ + return ("Welcome to System Installer Daemon POC
" + "Version: Unavailable") + + +@bp.route('/api/v0') +def apihome(): + """ + Not sure what this function should do, but have + a feeling that it should exist. + """ + return ("0") + diff --git a/src/applets/welcome/__init__.py b/src/applets/welcome/__init__.py new file mode 100644 index 0000000..e8226a2 --- /dev/null +++ b/src/applets/welcome/__init__.py @@ -0,0 +1,6 @@ +from flask import Blueprint + +bp = Blueprint('welcome', __name__) + +from applets.welcome import routes + diff --git a/src/applets/welcome/__pycache__/__init__.cpython-311.pyc b/src/applets/welcome/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..909e5ab Binary files /dev/null and b/src/applets/welcome/__pycache__/__init__.cpython-311.pyc differ diff --git a/src/applets/welcome/__pycache__/routes.cpython-311.pyc b/src/applets/welcome/__pycache__/routes.cpython-311.pyc new file mode 100644 index 0000000..137bc75 Binary files /dev/null and b/src/applets/welcome/__pycache__/routes.cpython-311.pyc differ diff --git a/src/applets/welcome/routes.py b/src/applets/welcome/routes.py new file mode 100644 index 0000000..cb567a8 --- /dev/null +++ b/src/applets/welcome/routes.py @@ -0,0 +1,20 @@ +from applets.welcome import bp + + +@bp.route('/welcome') +def welcome_index(): + """ + The page you'd get if you access the root of + this app in a browser. + """ + return ("Welcome to System Installer Daemon POC
" + "This is the Welcome Index") + + +@bp.route('/api/') +def api_home(): + """ + Wel + """ + return ("Welcome to the welcome API") + diff --git a/src/system-installer-daemon.py b/src/system-installer-daemon.py new file mode 100755 index 0000000..98294b2 --- /dev/null +++ b/src/system-installer-daemon.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +""" +Welcome to SID - The System Installer Daemon! +""" + + +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +from waitress import serve +import logging + +# configuration +VERSION = "0.00" +SECRET_KEY = "exampls" +DEV_MODE = 1 +APPS = "main welcome" + + +if DEV_MODE == 1: + print("Note: Starting in devmode!") + DEBUG = True + + +# create our application in flask +app = Flask(__name__) +app.config.from_object(__name__) + + +# Register blueprints here +for APP in APPS.split(" "): + print("Loading applet: %s " % APP) +from applets.main import bp as main_bp +app.register_blueprint(main_bp) +from applets.welcome import bp as welcome_bp +app.register_blueprint(welcome_bp) + + +@app.errorhandler(404) +def not_found(error): + return '404 Not Found', 404 + + +# configure logs +# logging.basicConfig() +logger = logging.getLogger('waitress') +if DEV_MODE == "1": + logger.setLevel(logging.DEBUG) + logger.debug("logger set to DEBUG") + + +if __name__ == '__main__': + if DEV_MODE: + serve(app, + host='0.0.0.0', + port=8080, + url_scheme='http', + expose_tracebacks=True) + else: + serve(app, + host='0.0.0.0', + port=8080, + url_scheme='https', + expose_tracebacks=False) +