Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Your First Application

Let’s create a simple Pilatus application to get familiar with the framework.

Creating a New Project

First, create a new Rust project:

mkdir my_project
cd my_project
printf '[workspace]\nmembers = ["app"]\nresolver="3"\n' > Cargo.toml
cargo new app
cd app
cargo add pilatus-rt pilatus-axum-rt

A Simple Example

Here’s a minimal example to get you started, which includes the axum webserver:

extern crate pilatus_rt;
extern crate pilatus_axum_rt;
fn main() {
    pilatus_rt::Runtime::default()
        .register(pilatus_axum_rt::register)
        .run();
}

Run the app

cargo run

Troubleshooting: Port 80 requires elevated privileges

ERROR: Hosted service ‘Main Webserver’ failed: Cannot open TCP-Connection for webserver. Is pilatus running already?

By default, Pilatus uses port 80 for the web interface. On some systems, this requires running with elevated privileges (sudo/root). To use a different port, create a data/config.json with the following content

{
  "web": {
    "socket": "0.0.0.0:8080"
  }
}

Test the app

curl http://localhost:80/api/time

This should show you the time on the system where the server is running. Congratulation, you just run your first pilatus app.

Next Steps

Now that you have a basic setup, we can add your first extension