Configs#
Panther collect all the configs from your core/configs.py
or the module you passed directly to Panther(configs=__name__)
MONITORING#
Type:
bool
(Default:False
)
It should be True
if you want to use panther monitor
command
and watch the monitoring
If True
:
- Log every request in
logs/monitoring.log
Requires watchfiles package.
LOG_QUERIES#
Type:
bool
(Default:False
)
If True
:
- Calculate every query
perf time
& Log them inlogs/query.log
MIDDLEWARES#
Type:
list
(Default:[ ]
)
List of middlewares you want to use
AUTHENTICATION#
Type:
str | None
(Default:None
)
Every request goes through authentication()
method of this class
(if auth = True
)
Requires python-jose package.
Example: AUTHENTICATION = 'panther.authentications.JWTAuthentication'
WS_AUTHENTICATION#
Type:
str | None
(Default:None
)
WebSocket requests goes through authentication()
method of this class
, before the connect()
(if auth = True
)
Example: WS_AUTHENTICATION = 'panther.authentications.QueryParamJWTAuthentication'
URLs#
Type:
str
(Required)
It can be optional if you pass your urls
directly to Panther(urls=url_routing)
It should be the address of your urls
dict
Example: URLs = 'core.configs.urls.url_routing'
DEFAULT_CACHE_EXP#
Type:
timedelta| None
(Default:None
)
We use it as default cache_exp_time
you can overwrite it in your @API
too
It is used when you set cache=True
in @API
decorator
Example: DEFAULT_CACHE_EXP = timedelta(seconds=10)
TEMPLATES_DIR#
Type:
str | list[str]
(Default:'tempaltes'
)
We use it when want to have different template directories
Example: `TEMPLATES_DIR = ['templates', 'app/templates']
THROTTLING#
Type:
Throttling | None
(Default:None
)
We use it as default throttling
you can overwrite it in your @API
too
Example: THROTTLING = Throttling(rate=10, duration=timedelta(seconds=10))
USER_MODEL#
Type:
str | None
(Default:'panther.db.models.BaseUser'
)
It is used for authentication
Example: USER_MODEL = 'panther.db.models.User'
JWTConfig#
Type:
dict | None
(Default:JWTConfig = {'key': SECRET_KEY}
)
We use it when you set panther.authentications.JWTAuthentication
as AUTHENTICATION
BACKGROUND_TASKS#
Type:
bool
(Default:False
)
If True
:
initialize()
thebackground_tasks
STARTUP#
Type:
str | None
(Default:None
)
It should be dotted address of your startup
function,
this function can be sync
or async
Example: STARTUP = 'core.configs.startup'
SHUTDOWN#
Type:
str | None
(Default:None
)
It should be dotted address of your shutdown
function
this function can be sync
or async
Example: SHUTDOWN = 'core.configs.shutdown'
AUTO_REFORMAT#
Type:
bool
(Default:False
)
It will reformat your code on every reload (on every change if you run the project with --reload
)
You may want to write your custom ruff.toml
in root of your project.
Requires ruff package.
Reference: https://docs.astral.sh/ruff/formatter/
Example: AUTO_REFORMAT = True
DATABASE#
Type:
dict
(Default:{}
)
We use it to create database
connection
REDIS#
Type:
dict
(Default:{}
)
Requires redis package.
We use it to create redis
connection
TIMEZONE#
Type:
str
(Default:'UTC'
)
Used in panther.utils.timezone_now()
which returns a datetime
based on your timezone
And panther.utils.timezone_now()
used in BaseUser.date_created
and BaseUser.last_login