Table of Contents
Modesanic.application.constantsServersanic.application.constantsServerStagesanic.application.constantsStrEnumsanic.application.constantssetup_extsanic.application.extget_logosanic.application.logoMOTDsanic.application.motdMOTDBasicsanic.application.motdMOTDTTYsanic.application.motdSpinnersanic.application.spinnerloadingsanic.application.spinnerApplicationServerInfosanic.application.stateApplicationStatesanic.application.statesanic.application.constants.Mode#
Server modes.
class Mode(value, names = None, module = None, qualname = None, type = None, start = 1, boundary = None)
sanic.application.constants.Server#
Server types.
class Server(value, names = None, module = None, qualname = None, type = None, start = 1, boundary = None)
sanic.application.constants.ServerStage#
Server stages.
class ServerStage(value, names = None, module = None, qualname = None, type = None, start = 1, boundary = None)
sanic.application.constants.StrEnum#
str(object='') -> str
class StrEnum(value, names = None, module = None, qualname = None, type = None, start = 1, boundary = None)
str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
sanic.application.ext.setup_ext#
Setup Sanic Extensions.
def setup_ext(app: Sanic, fail: bool = False, kwargs)
Requires Sanic Extensions to be installed.
Parameters
- app
Sanic Sanic application.
- fail
bool Raise an error if Sanic Extensions is not installed. Defaults to
False
.
- **kwargs
Keyword arguments to pass to
sanic_ext.Extend
.
Return
- sanic_ext.Extend
Sanic Extensions instance.
sanic.application.logo.get_logo#
Get the Sanic logo.
def get_logo(full: <class 'bool'> = False, coffee: <class 'bool'> = False): -> <class 'str'>
Will return the full color logo if the terminal supports it.
Parameters
- full
bool Use the full color logo. Defaults to
False
.
- coffee
bool Use the coffee logo. Defaults to
False
.
Return
- str
Sanic logo.
sanic.application.motd.MOTD#
Base class for the Message of the Day (MOTD) display.
class MOTD(logo: typing.Optional[str], serve_location: <class 'str'>, data: typing.Dict[str, str], extra: typing.Dict[str, str]): -> None
output#
Output the MOTD.
@classmethod
def output(logo: typing.Optional[str], serve_location: <class 'str'>, data: typing.Dict[str, str], extra: typing.Dict[str, str]): -> None
Parameters
- logo
Optional[str] Logo to display.
- serve_location
str Location to serve.
- data
Dict[str, str] Data to display.
- extra
Dict[str, str] Extra data to display.
sanic.application.motd.MOTDBasic#
A basic MOTD display.
class MOTDBasic(logo: typing.Optional[str], serve_location: <class 'str'>, data: typing.Dict[str, str], extra: typing.Dict[str, str]): -> None
This is used when the terminal does not support ANSI escape codes.
output#
Output the MOTD.
def output(logo: typing.Optional[str], serve_location: <class 'str'>, data: typing.Dict[str, str], extra: typing.Dict[str, str]): -> None
Parameters
- logo
Optional[str] Logo to display.
- serve_location
str Location to serve.
- data
Dict[str, str] Data to display.
- extra
Dict[str, str] Extra data to display.
sanic.application.motd.MOTDTTY#
A MOTD display for terminals that support ANSI escape codes.
class MOTDTTY(args, kwargs): -> None
display#
Display the MOTD.
def display(self, version = True, action = Goin' Fast, out = None)
Parameters
- version
bool Display the version. Defaults to
True
.
- action
str Action to display. Defaults to
"Goin' Fast"
.
- out
Optional[Callable] Output function. Defaults to
None
.
output#
Output the MOTD.
def output(logo: typing.Optional[str], serve_location: <class 'str'>, data: typing.Dict[str, str], extra: typing.Dict[str, str]): -> None
Parameters
- logo
Optional[str] Logo to display.
- serve_location
str Location to serve.
- data
Dict[str, str] Data to display.
- extra
Dict[str, str] Extra data to display.
sanic.application.spinner.Spinner#
Spinner class to show a loading spinner in the terminal.
class Spinner(message: <class 'str'>): -> None
Used internally by the loading
context manager.
cursor#
@staticmethod
def cursor()
hide#
@staticmethod
def hide()
run#
def run(self)
show#
@staticmethod
def show()
start#
def start(self)
stop#
def stop(self)
sanic.application.spinner.loading#
def loading(message: <class 'str'> = Loading)
sanic.application.state.ApplicationServerInfo#
Information about a server instance.
class ApplicationServerInfo(settings: Dict[str, Any], stage: ServerStage = 1, server: Optional[AsyncioServer] = None): -> None
sanic.application.state.ApplicationState#
Application state.
class ApplicationState(app: Sanic, asgi: bool = False, coffee: bool = False, fast: bool = False, host: str = "", port: int = 0, ssl: Optional[SSLContext] = None, sock: Optional[socket] = None, unix: Optional[str] = None, mode: Mode = production, reload_dirs: Set[Path] = <factory>, auto_reload: bool = False, server: Server = sanic, is_running: bool = False, is_started: bool = False, is_stopping: bool = False, verbosity: int = 0, workers: int = 0, primary: bool = True, server_info: List[ApplicationServerInfo] = <factory>, _init: bool = False): -> None
This class is used to store the state of the application. It is
instantiated by the application and is available as app.state
.
is_debug#
Check if the application is in debug mode.
@property
def is_debug(self): -> bool
Return
- bool
True
if the application is in debug mode,False
otherwise.
set_mode#
def set_mode(self, value: Union[str, Mode])
set_verbosity#
Set the verbosity level.
def set_verbosity(self, value: int): -> None
Parameters
- value
int Verbosity level.