2# +==== BEGIN CatFeeder =================+
5# ...............)..(.')
7# ...............\(__)|
8# Inspired by Joan Stark
9# source https://www.asciiart.eu/
14# CREATION DATE: 19-11-2025
15# LAST Modified: 23:3:21 10-01-2026
17# This is the backend server in charge of making the actual website work.
19# COPYRIGHT: (c) Cat Feeder
20# PURPOSE: The main class required to set up the environement for the server to run properly.
22# +==== END CatFeeder =================+
25from display_tty
import Disp, initialise_logger
27from .bucket
import Bucket
28from .e_mail
import MailManagement
29from .path_manager
import PathManager
30from .docs
import DocumentationHandler
31from .image_reducer
import ImageReducer
32from .server_header
import ServerHeaders
33from .crons
import BackgroundTasks, Crons
34from .endpoint_manager
import EndpointManager
35from .utils
import CONST, OAuthAuthentication
36from .favicon
import FaviconUser, FaviconAdmin
37from .core
import ServerManagement, FinalClass, RuntimeControl, RuntimeManager, RI
38from .boilerplates
import BoilerplateIncoming, BoilerplateNonHTTP, BoilerplateResponses
45 disp: Disp = initialise_logger(__qualname__,
False)
47 def __init__(self, host: str =
"0.0.0.0", port: int = 5000, success: int = 0, error: int = 84, app_name: str =
"Asperguide", debug: bool =
False) ->
None:
49 This is the class Server, a class that contains the structures used to allow the uvicorn and fastapi combo to run successfully.
50 host (str, optional): _description_. Defaults to "0.0.0.0".
51 port (int, optional): _description_. Defaults to 5000.
52 character_folder (str, optional): _description_. Defaults to "".
53 usr_db_path (str, optional): _description_. Defaults to "".
54 success (int, optional): _description_. Defaults to 0.
55 error (int, optional): _description_. Defaults to 84.
56 app_name (str, optional): _description_. Defaults to "Desktop Pets".
57 debug (bool, optional): _description_. Defaults to False.
60 self.
disp.update_disp_debug(debug)
61 self.
disp.log_debug(
"Initialising...")
71 RuntimeManager.update_debug(self.
debug)
72 RI.update_debug(self.
debug)
86 self.
disp.log_debug(
"Initialising database link.",
"__init__")
91 username=CONST.DB_USER,
92 password=CONST.DB_PASSWORD,
93 db_name=CONST.DB_DATABASE,
115 BoilerplateResponses,
116 **{
"debug": self.
debug}
143 DocumentationHandler,
170 self.
disp.log_debug(
"Initialised")
174 The destructor of the class.
176 self.
disp.log_info(
"The server is shutting down.",
"__del__")
181 The main function of the server.
182 This is the one in charge of starting the server.
194 "Error: background tasks failed to start.",
200 raise RuntimeError(
"No server to start")
202 except Exception
as e:
203 self.
disp.log_error(f
"Error: {e}",
"main")
209 The function in charge of checking if the server is running.
212 bool: _description_: Returns True if the server is running.
218 The function in charge of stopping the server.
220 title =
"stop_server"
221 self.
disp.log_info(
"Stopping server", title)
226 self.
disp.log_info(
"Server stopped", title)
BackgroundTasks background_tasks_initialised
ServerManagement server_management_initialised
RuntimeControl runtime_control
RuntimeManager runtime_manager
None __init__(self, str host="0.0.0.0", int port=5000, int success=0, int error=84, str app_name="Asperguide", bool debug=False)
PathManager paths_initialised