Skip to content

shipany.bot.contrib.fastapi

shipany.bot.contrib.fastapi package

Submodules

shipany.bot.contrib.fastapi.app module

Web server for handling incoming webhooks.

shipany.bot.contrib.fastapi.app.app = <fastapi.applications.FastAPI object>

The FastAPI app.

  • Parameters:
    • scope (MutableMapping *[*str , Any ])
    • receive (Callable [ [ ] , Awaitable *[*MutableMapping *[*str , Any ] ] ])
    • send (Callable [ *[*MutableMapping *[*str , Any ] ] , Awaitable *[*None ] ])
  • Return type: None

async shipany.bot.contrib.fastapi.app.root()

Root endpoint which responds with the bot’s information.

  • Return type: str

shipany.bot.contrib.fastapi.app.header_checks(expectations)

Check the headers of the request.

  • Parameters: expectations (t.Mapping *[*str , str ]) — The expected headers.
  • Returns: The dependency function.
  • Return type: t.Callable[[Request], None]

shipany.bot.contrib.fastapi.app.query_param_checks(expectations)

Check the query parameters of the request.

  • Parameters: expectations (t.Mapping *[*str , str ]) — The expected query parameters.
  • Returns: The dependency function.
  • Return type: t.Callable[[Request], None]

shipany.bot.contrib.fastapi.app.add_webhooks(flow)

Add webhooks to the FastAPI app.

Expects the flow object to have webhooks.

  • Parameters: flow (Flow) — flow object
  • Return type: None

shipany.bot.contrib.fastapi.bindings module

shipany.bot.contrib.fastapi.bindings.default_bindings(binder)

Bind the default dependencies.

  • Parameters: binder (Binder) — The dependency injector binder.
  • Return type: None

shipany.bot.contrib.fastapi.server module

class shipany.bot.contrib.fastapi.server.FastApiWebServer

Bases: WebServer

FastAPI web server.

serve(flow, app_config=None)

Start the web server.

Before starting the server, it adds the webhooks to the FastAPI app.

To change the host and port, update the WEB_SERVER_HOST and WEB_SERVER_PORT in the environment.

  • Parameters:
    • flow (Flow) — the flow to be used by the server
    • app_config (ApplicationConfig , optional) — the application configuration. Defaults to None.
    • self (Self)
  • Returns: coroutine to start the server in the event loop
  • Return type: t.Coroutine[t.Any, t.Any, None]

Module contents