|
||
---|---|---|
backend | ||
frontend | ||
.gitignore | ||
docker-compose.yml | ||
Dockerfile | ||
README.md |
🌐 Wake on LAN API
Python REST API that wakes a machine (that supports WoL) from outside the local network.
📦 Installation
Note
We currently bake the
backend/.env
file into the Docker image, which is considered bad practice. This might be fixed in future updates.
🐳 Docker Compose (recommended)
Clone the repository:
git clone https://github.com/Urpagin/WoL_Api/
Navigate to the repository:
cd WoL_Api
Create and populate your .env
file:
vim .env
Add the following to .env
:
HASHED_KEY=<HASHEDKEY>
Use this tool to hash your password with SHA384.
Launch the Docker Compose setup:
sudo docker compose up -d
🐳 Docker
Follow the steps in Docker Compose up to and including the .env
setup.
Then build the Docker image:
docker build -t urpagin/wol-api:0.0.1 .
Check the image ID:
docker images
Run the Docker container (replace <IMAGEID>
with the actual image ID):
docker run -d --restart=always --network host --name wol-api <IMAGEID>
🐍 Python
Follow the steps in Docker Compose up to and including the .env
setup.
Install the dependencies:
pip install -r backend/requirements.txt
Run the application from the root directory (not from inside backend
):
python backend/main.py
✅ It's Saul Goodman! Execute docker ps
to list running containers or docker ps -a
to view both running and stopped containers, useful if wol-api
crashes.
⚙️ API Specifications
/
(GET): Simple static HTTP endpoint to check API status./wake
(POST): Acceptskey
andip
; wakes a machine using a magic packet./ping
(GET): Acceptskey
andip
; returns the ping response from the machine./add-machine
(PUT): Acceptskey
andip
; retrieves the MAC address ofip
and stores the tuple(ip, mac)
in the database./database
(GET): Acceptskey
; returns the database content as a list.
Note: All responses are JSON formatted: {"detail": <RESPONSE>}
.
Note: Before using /wake
, ensure you've added the machine's MAC address to the database using /add-machine
.
Image Credits: Image by www.slon.pics on Freepik.