2# +==== BEGIN CatFeeder =================+
5# ...............)..(.')
7# ...............\(__)|
8# Inspired by Joan Stark
9# source https://www.asciiart.eu/
14# CREATION DATE: 13-01-2026
15# LAST Modified: 22:16:13 14-01-2026
17# This is the backend server in charge of making the actual website work.
19# COPYRIGHT: (c) Cat Feeder
20# PURPOSE: File in charge of containing the settings for the core functionalities of the server.
22# +==== END CatFeeder =================+
25from typing
import List
26from display_tty
import Disp, initialise_logger
28from ..config
import TOMLLoader, refresh_debug
30from ..utils
import constants
as CONST
36IDISP: Disp = initialise_logger(
"CORE Constants", refresh_debug(CONST.DEBUG))
39TOML_MIDDLEWARE_SECTION =
"Server_configuration.middleware."
44GZIP_MINIMUM_SIZE: int = TOML.get_toml_variable(
45 f
"{TOML_MIDDLEWARE_SECTION}gzip",
"minimum_size", 500
49GZIP_COMPRESSION_LEVEL: int = TOML.get_toml_variable(
50 f
"{TOML_MIDDLEWARE_SECTION}gzip",
"compression_level", 9
55CORS_ALLOW_ORIGINS: List[str] = TOML.get_toml_variable(
56 f
"{TOML_MIDDLEWARE_SECTION}cors",
"allow_origins", [
"*"]
60CORS_ALLOW_CREDENTIALS: bool = TOML.get_toml_variable(
61 f
"{TOML_MIDDLEWARE_SECTION}cors",
"allow_credentials",
True
65CORS_ALLOW_METHODS: List[str] = TOML.get_toml_variable(
66 f
"{TOML_MIDDLEWARE_SECTION}cors",
"allow_methods", [
"*"]
70CORS_ALLOW_HEADERS: List[str] = TOML.get_toml_variable(
71 f
"{TOML_MIDDLEWARE_SECTION}cors",
"allow_headers", [
"*"]
76SERVER_PROD_FORCE_HTTPS: bool = TOML.get_toml_variable(
77 f
"{TOML_MIDDLEWARE_SECTION}https",
"force_https",
True
81TRUSTED_HOSTS_LIST: List[str] = TOML.get_toml_variable(
82 f
"{TOML_MIDDLEWARE_SECTION}trusted_hosts",
"host", []
85if not SERVER_PROD_FORCE_HTTPS:
86 LOCAL_HOSTS: List[str] = TOML.get_toml_variable(
87 f
"{TOML_MIDDLEWARE_SECTION}trusted_hosts",
"dev_hosts",
88 [
"localhost",
"127.0.0.1",
"::1"]
90 TRUSTED_HOSTS_LIST.extend(LOCAL_HOSTS)
92IDISP.log_info(
"Core constants loaded configurations.")
93IDISP.log_debug(f
"GZIP_MINIMUM_SIZE: {GZIP_MINIMUM_SIZE}")
94IDISP.log_debug(f
"GZIP_COMPRESSION_LEVEL: {GZIP_COMPRESSION_LEVEL}")
95IDISP.log_debug(f
"CORS_ALLOW_ORIGINS: {CORS_ALLOW_ORIGINS}")
96IDISP.log_debug(f
"CORS_ALLOW_CREDENTIALS: {CORS_ALLOW_CREDENTIALS}")
97IDISP.log_debug(f
"CORS_ALLOW_METHODS: {CORS_ALLOW_METHODS}")
98IDISP.log_debug(f
"CORS_ALLOW_HEADERS: {CORS_ALLOW_HEADERS}")
99IDISP.log_debug(f
"SERVER_PROD_FORCE_HTTPS: {SERVER_PROD_FORCE_HTTPS}")
100IDISP.log_debug(f
"TRUSTED_HOSTS_LIST: {TRUSTED_HOSTS_LIST}")