Serving¶
Built-in¶
yli includes a trio-powered webserver that can be used to serve your app. Webserver
takes a list of BindInfo
, and a single parameter that is your application function.
from yli.http import Webserver, BindInfo
async def main():
webserver = Webserver([BindInfo(7777)], app)
await webserver.run()
trio.run(main)
SSL¶
SSL support can be enabled by passing a SSLContext
to BindInfo:
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ctx.load_cert_chain("cert.pem", "key.pem")
s = Webserver([BindInfo(7777), BindInfo(7778, ssl_context=ctx)], app)
await s.run()