From 12e943f65c784074d11b3dac5a8afb50f7d275a9 Mon Sep 17 00:00:00 2001 From: Jonathan Carter Date: Sat, 30 Mar 2024 22:37:58 +0200 Subject: [PATCH] Initial layout --- src/applets/main/__init__.py | 6 ++ .../main/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 367 bytes .../main/__pycache__/routes.cpython-311.pyc | Bin 0 -> 886 bytes src/applets/main/routes.py | 21 ++++++ src/applets/welcome/__init__.py | 6 ++ .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 376 bytes .../__pycache__/routes.cpython-311.pyc | Bin 0 -> 860 bytes src/applets/welcome/routes.py | 20 ++++++ src/system-installer-daemon.py | 65 ++++++++++++++++++ 9 files changed, 118 insertions(+) create mode 100644 src/applets/main/__init__.py create mode 100644 src/applets/main/__pycache__/__init__.cpython-311.pyc create mode 100644 src/applets/main/__pycache__/routes.cpython-311.pyc create mode 100644 src/applets/main/routes.py create mode 100644 src/applets/welcome/__init__.py create mode 100644 src/applets/welcome/__pycache__/__init__.cpython-311.pyc create mode 100644 src/applets/welcome/__pycache__/routes.cpython-311.pyc create mode 100644 src/applets/welcome/routes.py create mode 100755 src/system-installer-daemon.py 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 0000000000000000000000000000000000000000..ed1a5d58fe97eeb68483056cd62746734f0463e6 GIT binary patch literal 367 zcmZuqyG{c!5M1A#qwoklq9APw;*JU-#0StI3ep&Zm*l|q9kvsZE+r)$e*i-KOpqwh zRgtLZkkX}MPlN)A(Y|+f_Nmoc1;XY{^YV=HN8S7)TNd+ODjq+uPieDNPu6;_} zswt&Y7Nx9`^Ril3Woa;mZhhoA5uRaQYc5WNR#Azo!l^h=PG}sV5re!x7!@X}K8i37 z5$#UyLR7|}rvtQw6Tx4IrL3rBg_OC=qmD}o5_LaBaczcq}V0-$X`85*x25(wr#{d8T literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..8fa8c2022b504cc18aa0d043aeed4e86d32ad3b2 GIT binary patch literal 886 zcma)4&1(}u6rb6A8WO9ef*^$l6(pdUo~0C|UV5oY{eXgp$?haOWwVpc%x;^UD&)|= zK>ve^^q*1iAba)XZ6&vye6#5ajTav~Ki<53zxVNDK6g4Tg0_Fs9DJmN{B)PnD%Z|D zMduRb zbZO@G#|z5*zZKDO{oIW6Is(o|G2ffMY605oP{5cE1x!@(D1f1`AP4RO-1mhsU@<`} zWkC%Jf(@ksJ|2UNfkR)bQzLY*_%(g@PDH*M39t$dC&r2q?8nCPC=wc;b1_meynL|- zJADmo_pQ)Is`x3qiFwLp#QTx>LbMxlj)yD`S->r4$13JF?{I~HKw~IY{PH^STIcJt`xjduHfNi; oSEmnig7CXSytOj0UM6+F(T(qPBll|bZcY$f+Pxc*B3vx+2U70RTmS$7 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..909e5abff01399f405a3f08a685299b9ead4195a GIT binary patch literal 376 zcmZuqy-EW?5T3ou#;8QW*3LAhFxy#)h!0?6qiL2kJ4sG=_m167Bwb41K%YPnUnYWu zTotgg6Vjz}f@dN4G5_<;H&4yx1`u{aqu;0ev1)!%tBS=T75AV)GXs`&8G{6n=>(I< z1mK1I2i=r7si|4sNl-sH(493u@?mQ>XGb~oh%L}1ZRN^{!Dh`zs8pmkFFdGcVxru6k zB1}R=dyu&hl`-h)0B!C>@I6r}i%MBYnYk=V*(oN=#*xkS$l$SW(j!J5PAGh(jInpv eo&B{r-wsq> zr+e>S(VelRZ1=!)!ebEH!ciXa&)-2hW?WRb{lKC?2kcnnfsTWmMSRXv7AMnqE>ew? zGgTwKNLnN;Fi1?vkl~;y*Q%w3Niox04U0wTHB22P22#3+)j?H#G^bGYiTAt$G}4f^ zbg)yx{)1JoW&+n)G4ixs3>h(dHlXz7-l*PjWekMeKvTL1a}?tRO7rR-pep0wKt1sM z%l>Mdx4u(8Y*rgKEv32P(y14$x2Zd<^}ls@G7-&EzAHUUHxEO7LQ~m" + "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) +