Pyjo.UserAgent.Server - Application server

from Pyjo.UserAgent.Server import Server

server = Server()
print(server.url())

# Or import the module, as in Google Python Style Guide

import Pyjo.UserAgent.Server

server = Pyjo.UserAgent.Server.new()
print(server.url())

Pyjo.UserAgent.Server is an embedded web server based on Pyjo.Server.Daemon that processes requests for Pyjo.UserAgent.

The end of a with block closes its servers.

See also

Pyjoyment, https://mojolicious.org.

Ported from Mojo::UserAgent::Server of Mojolicious 9.49.

Classes

class Pyjo.UserAgent.Server.Pyjo_UserAgent_Server(*, app: Application | None = None, ioloop: Pyjo_IOLoop | None = None)[source]

Pyjo.UserAgent.Server inherits all methods from Pyjo.Base and implements the following new ones.

property app: Application | None[source]
app = server.app
server.app = Pyjoyment.new()

Application this server handles, instance specific applications override the global default, which app() of the module gives.

close() → None[source]
server.close()

Close the servers, as the end of a with block does, which start again on new ports when they are used again.

ioloop: Pyjo_IOLoop
loop = server.ioloop
server.ioloop = Pyjo.IOLoop.new()

Event loop object to use for I/O operations, defaults to the global Pyjo.IOLoop singleton.

nb_url(proto: str | None = None) → Pyjo_URL[source]
url = server.nb_url()
url = server.nb_url('http')
url = server.nb_url('https')

Get absolute Pyjo.URL object for server processing non-blocking requests with app and switch protocol if necessary.

restart() → None[source]
server.restart()

Restart server with new port.

url(proto: str | None = None) → Pyjo_URL[source]
url = server.url()
url = server.url('http')
url = server.url('https')

Get absolute Pyjo.URL object for server processing blocking requests with app and switch protocol if necessary.

Pyjo.UserAgent.Server.app(value: Application | None = None) → Application | None[source]
app = Pyjo.UserAgent.Server.app()
Pyjo.UserAgent.Server.app(Pyjoyment.new())

The global default application of the servers, as Mojo calls app on the class.

# Change application behavior
Pyjo.UserAgent.Server.app().log.level = 'fatal'