Click on the button below to launch the XKCD Generator on Cosmonic Now:
The XKCD image generator application is a simple HTTP application that randomly produces random XKCD comics on demand. It illustrates how to build a fully functioning application with a single actor and a few capability providers. You can find the inspiration and architecture diagram for this application in the Cosmonic documentation.
This example actor makes use of three capabilities:
wasmcloud:httpserver
for responding to http requestswasmcloud:httpclient
for fetching http resources from the internetwasmcloud:builtin:numbergen
for generating a random number.
Each time you refresh the page, you should get a random xkcd comic!
Ensure you have a Rust toolchain and the wasm32-unknown-unknown
target installed, then simply run cosmo build
to build and sign this actor. The total size of this WebAssembly module, when compiled with Rust is approximately 219kb.
Follow the guide on Cosmonic's documentation site.
Cosmonic developers built this actor live on stream, including the thought process behind the code here and explanations about the components that went into this application. Check it out!