This is a simple Wakeup on LAN (WoL) service built using FastAPI. It provides an HTTP API and a web interface to wake up network devices over the local area network.
Project description
Wakeup on LAN Service
Project Overview
This is a simple Wakeup on LAN (WoL) service built using FastAPI. It provides a secure HTTP API and a web interface to wake up network devices.
The application is designed to be configured via environment variables and can be run directly as a Python package or as a Docker container.
Quick Start
This section provides a summary for the two most common use cases: running the service as a user and setting up a development environment.
Option 1: Run as a Standalone Service (User)
This is the simplest way to run the service without cloning the project repository.
- Install the package from PyPI:
pip install wol-service
- Run the service:
Pass all required environment variables directly on the command line. This example enables authentication and saves data to a
datasubdirectory.# Create a directory for persistent data mkdir -p data # Run the server SECRET_KEY='a-very-strong-and-long-secret-key' \ ADMIN_USERNAME='admin' \ ADMIN_PASSWORD='a-good-password' \ USERS_PATH='./data/users.json' \ WOL_HOSTS_PATH='./data/hosts.json' \ uvicorn wol_service.app:app --host 0.0.0.0 --port 25644
- Access the service at http://localhost:25644.
Option 2: Run for Development (Developer)
This method uses the cloned repository and Docker Compose, which is recommended for development.
- Clone the repository:
git clone https://github.com/your-repo/wol-service.git cd wol-service
- Set up your environment:
# Create a .env file from the template cp .env.in .env # Edit .env and set your secrets nano .env
- Start the service:
The provided helper script builds the image and starts the development container.
./scripts/docker_compose_up.sh
- Access the service at http://localhost:25644.
Detailed Configuration
The application is configured entirely via environment variables.
Environment Variables
| Variable | Description | Default |
|---|---|---|
SECRET_KEY |
Required. A long, random string used to sign JWT cookies. The app will not start without this. | None |
ADMIN_USERNAME |
Username for the initial admin account. If empty, authentication is disabled. | None |
ADMIN_PASSWORD |
Password for the initial admin account. If empty, authentication is disabled. | None |
USERS_PATH |
Path to the JSON file for storing hashed user records. | users.json |
WOL_HOSTS_PATH |
Path to the JSON file for storing saved WoL hosts. | hosts.json |
COOKIE_SECURE |
Set to true if running on HTTPS. If false, cookies are sent over HTTP. |
false |
COOKIE_SAMESITE |
Cookie SameSite policy. Can be lax, strict, or none. |
lax |
ACCESS_TOKEN_EXPIRE_MINUTES |
How long a login session (JWT token) is valid in minutes. | 30 |
Authentication Modes
- Authenticated (Recommended): Set
ADMIN_USERNAMEandADMIN_PASSWORD.- Credentials are hashed and stored in
USERS_PATHon the first boot. - For security, the credential environment variables are cleared from memory after startup.
- CSRF protection is enabled for all state-changing requests.
- Credentials are hashed and stored in
- Unauthenticated (Insecure): Leave
ADMIN_USERNAMEandADMIN_PASSWORDunset or empty.- Authentication and CSRF protections are disabled.
- This mode is only safe on a strictly trusted private network.
Advanced Usage and Development
Docker Compose (Development)
The docker-compose.yml file defines multiple services. For local development, you should use the wol-service-local service, which mounts your local source code into the container. See the Quick Start section for instructions.
Note on Compose Services: The
docker-compose.ymlalso contains awol-servicethat simulates a production environment by building fromDockerfile.pypiand installing the package from a registry. This is useful for testing the packaged version of the application.
Standalone Docker Image
You can build a Docker image directly from the source code.
- Build the image:
./scripts/docker_build.sh
- Run the container:
This command mounts a local
./datadirectory to persist users and hosts and uses an.envfile for configuration.mkdir -p data docker run -d -p 25644:25644 --name wol-service-container \ --env-file .env \ -e WOL_HOSTS_PATH=/data/hosts.json \ -e USERS_PATH=/data/users.json \ -v "$(pwd)/data:/data" \ wol-service:latest
Python (Local Development)
- Install dependencies:
Ensure you have
uvinstalled (pip install uv), then run:uv pip install -e '.[dev]'
- Run the application:
This command sources your
.envfile and starts the server with hot-reloading.set -a; source .env; set +a uvicorn src.wol_service.app:app --reload --host 0.0.0.0 --port 25644
Testing and Linting
This project uses pytest for testing and ruff for linting.
- Run tests:
./scripts/run_tests.sh
- Run linter:
uv run ruff check .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wol_service-0.1.0rc3.tar.gz.
File metadata
- Download URL: wol_service-0.1.0rc3.tar.gz
- Upload date:
- Size: 125.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c4d6a06298ff5b85312f80f6cf5d34d28f59a281147ed7a1b80c7654da54d9a
|
|
| MD5 |
e17714ac947353b8abcd2eed3587a93e
|
|
| BLAKE2b-256 |
228ba2c427c67dd62aabf57000f2d4d70e1437ad6519740527395791a74ed462
|
File details
Details for the file wol_service-0.1.0rc3-py3-none-any.whl.
File metadata
- Download URL: wol_service-0.1.0rc3-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50d0fb14c500eccadd046041f9dd45450468fa36fe1f44d5204748b36c88b0b9
|
|
| MD5 |
7d7ed75a16acafcb8e5755bd1576c478
|
|
| BLAKE2b-256 |
1ae764e857f5d205d80e00bb93e2b2e63b874dc40d822686f8a0d7d8054870ce
|