tilie_server.cli#
The tilie command: start the server and open the editor, or serve it publicly.
- tilie_server.cli.PUBLIC_BIND = '0.0.0.0'#
The address a public run binds: every interface, so that a proxy or a container’s port mapping reaches it.
- tilie_server.cli.free_port()[source]#
A port that was free on the loopback interface a moment ago.
- Return type:
- tilie_server.cli.port_is_free(port)[source]#
Whether
portcould be bound on the loopback interface a moment ago.The port is bound as the server binds it: with
SO_REUSEADDRoutside Windows, so that the connections of a run just stopped do not hold it. On Windows the option would let a second socket share a port in use.
- tilie_server.cli.choose_port(requested, default=8000)[source]#
The port to listen on, and the notice to print about it, if any.
- Parameters:
- Returns:
The port and
None; or, when no port is requested anddefaultis in use, a free port and the notice saying so.- Return type:
- tilie_server.cli.public_host(given)[source]#
A host name
--public-hostgives; refused when empty, since an empty name would admit a request with an emptyHostheader.
- tilie_server.cli.EXCLUDED_BY_PUBLIC_HOST = ('check', 'root', 'no_browser')#
The options a public run refuses: it checks nothing, serves no files and opens no browser.
- tilie_server.cli.parse_args(argv)[source]#
Parse the command line of
tilie;Nonereadssys.argv.An option a public run excludes is an error next to
--public-host;--rootdefaults to the home folder only after that check.
- tilie_server.cli.settings_for(args, port)[source]#
The settings of the run
argsasks for, onport.A public run binds every interface, answers as the given hosts, checks no token, serves no files, bounds request bodies and posted tables, and limits its computations and connections; a local run binds the loopback interface with a new token and serves the files below its root.
- Parameters:
- Return type:
- tilie_server.cli.uvicorn_config(app, settings, *, check)[source]#
The uvicorn configuration of a run of
appwithsettings.- Parameters:
app (FastAPI) – The application.
settings (ServerSettings) – The run’s settings, whose
connectionsuvicorn keeps.check (bool) – Whether the run is a
--check, which logs only errors and no access lines.
- Return type:
Config
- tilie_server.cli.public_notice(settings)[source]#
The line a public run prints once it listens.
- Parameters:
settings (ServerSettings)
- Return type:
- tilie_server.cli.wait_until_started(server)[source]#
Wait until
serverlistens, requesting shutdown on a timeout.- Parameters:
server (Server)
- Return type:
- tilie_server.cli.run_server(server, on_started)[source]#
Run uvicorn in the main thread and perform
on_startedalongside it.Uvicorn can install its SIGINT and SIGTERM handlers only in the main thread. The short-lived observer does no server work; it waits for startup and then prints or verifies the URL.
- tilie_server.cli.fetch(url, token)[source]#
GET
urlwith the bearer token and return status and body.
- exception tilie_server.cli.CheckFailed[source]#
Bases:
ExceptionA
--checkverification step did not pass.
- tilie_server.cli.verify(base_url, token)[source]#
Verify the health endpoint and the editor; return the health document.
- tilie_server.cli.main(argv=None)[source]#
Run the
tiliecommand and return its exit status.A public run prints what it serves; a
--checkrun prints the health document once the checks pass, then stops; a local run prints the editor’s URL, the token in its fragment, and opens a browser unless--no-browseris given.