One Actor server
The one actor server is intended to provide an ActivityPub actor to run tests with (see here). For this, one runs the server via
Then one can use the actor from inside a python script via
from fediverse_pasture.one_actor import bovine_actor_and_actor_object
bovine_actor, actor = bovine_actor_and_actor_object("http://localhost:2917/")
await bovine_actor.init(session=session)
where session
represents an aiohttp.ClientSession. Furthermore,
one_actor
exposes a page at /
that displays objects received in
the inbox. Due to the simplistic implementation, one can only open the
page once, and the current content is lost on a refresh.
Command line usage
python -m fediverse_pasture.one_actor
Usage:
Options:
--only_generate_config
--assets TEXT Directory to serve assets from. Assets will be
served under /assets/
--port INTEGER port to run on
--reload
--help Show this message and exit.
The domain name the actor objects return is interfered from the host the request is made to. This means specifying the domain is only necessary, when using the actor in an external application.
Exported methods
fediverse_pasture.one_actor
bovine_actor_and_actor_object(domain)
Returns the BovineActor and the Actor object corresponding to the actor being served by one_actor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain |
str
|
The domain the actor lives on |
required |
Returns:
Type | Description |
---|---|
Tuple[BovineActor, Actor]
|
BovineActor and Actor object |
Source code in fediverse_pasture/one_actor.py
Serving static files
Using the --assets
parameter, a directory can be specified to be served
as static files. This is done using the method
fediverse_pasture.server.assets_blueprint_for_directory(directory)
Returns a Blueprint that serves the directory
as static files. Files ending in .jsonap
will be served with
content-type application/activity+json
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
directory |
str
|
Directory to serve static files from |
required |