tiled.server.SimpleTiledServer#

class tiled.server.SimpleTiledServer(directory: str | Path | None = None, api_key: str | None = None, port: int = 0, readable_storage: str | Path | list[str | Path] | None = None)[source]#

Run a simple Tiled server on a background thread.

This is intended to be used for tutorials and development. It employs only basic security and should not be used to store anything important. It does not scale to large number of users. By default, it uses temporary storage.

Parameters:
directoryOptional[Path, str]

Location where data, including files and embedded databases, will be stored. By default, a temporary directory will be used.

api_keyOptional[str]

By default, an 8-bit random secret is generated. (Production Tiled servers use longer secrets.)

portOptional[int]

Port the server will listen on. By default, a random free high port is allocated by the operating system.

readable_storageOptional[Union[str, pathlib.Path, list[Union[str, pathlib.Path]]]

If provided, the server will be able to read from these storage locations, in addition to the default storage location defined by directory.

Examples

Run a server and connect to it.

>>> from tiled.server import SimpleTiledServer
>>> from tiled.client import from_uri
>>> ts = SimpleTiledServer()
>>> client = from_uri(ts.uri)

Locate server data, databases, and log files.

>>> ts.directory

Run a server with persistent storage that can be reused.

>>> ts = SimpleTiledServer("my_data/")
__init__(directory: str | Path | None = None, api_key: str | None = None, port: int = 0, readable_storage: str | Path | list[str | Path] | None = None)[source]#

Methods

__delattr__(name, /)

Implement delattr(self, name).

__dir__(/)

Default dir() implementation.

__enter__()

__eq__(value, /)

Return self==value.

__exit__(*args)

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getstate__(/)

Helper for pickle.

__gt__(value, /)

Return self>value.

__hash__(/)

Return hash(self).

__init__([directory, api_key, port, ...])

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(*args, **kwargs)

__reduce__(/)

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__(/)

Size of object in memory, in bytes.

__str__(/)

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

_repr_html_()

close()

Attributes

__annotations__

__dict__

__doc__

__module__

__weakref__

list of weak references to the object