Aeros.WebServer

Main web server instance

Module Contents

Classes

WebServer

This is the main server class which extends a standard Flask class by a bunch of features and major

Functions

make_config_from_hypercorn_args(hypercorn_string: str, config: Config = Config()) → Config

Overrides a given config’s items if they are specified in the hypercorn args string

Aeros.WebServer.make_config_from_hypercorn_args(hypercorn_string: str, config: Config = Config()) → Config[source]

Overrides a given config’s items if they are specified in the hypercorn args string

class Aeros.WebServer.WebServer(import_name: str, host: str = '0.0.0.0', port: int = 80, include_server_header: bool = True, hypercorn_arg_string: str = '', worker_threads: int = 1, logging_level: Union[int, str] = 'INFO', cache: Cache = Cache(), compression: Compression = Compression(level=2, min_size=10), global_headers: Dict[str, str] = None, *args, **kwargs)[source]

Bases: Aeros.patches.quart.app.Quart

This is the main server class which extends a standard Flask class by a bunch of features and major performance improvements. It extends the Quart class, which by itself is already an enhanced version of the Flask class. This class however allows production-grade deployment using the hypercorn WSGI server as production server. But instead of calling the hypercorn command via the console, it can be started directly from the Python code itself, making it easier to integrate in higher-level scripts and applications without calling os.system() od subprocess.Popen().

_get_own_instance_path(self)[source]

Retrieves the file and variable name of this instance to be used in the Hypercorn CLI.

Since hypercorn needs the application’s file and global variable name, an instance needs to know it’s own origin file and name. But since this class is not defined in the same file as it is called or defined from, this method searches for the correct module/file and evaluates it’s instance name.

Warning

Deprecation warning: This method will be removed in future versions. Usage is highly discouraged.

cache(self, timeout=None, key_prefix='view/%s', unless=None, forced_update=None, response_filter=None, query_string=False, hash_method=hashlib.md5, cache_none=False)[source]

A simple wrapper that forwards cached() decorator to the internal Cache() instance. May be used as the normal @cache.cached() decorator.

run_server(self) → None[source]

Generates the necessary config and runs the server instance.