A simple project that allows you to send Wake-on-LAN (WoL) magic packets via HTTP requests. It consists of two scripts: main.py for sending the WoL packets and server.py for handling HTTP requests that trigger the main.py script.
-
Python: Ensure you have Python installed in your machine.
-
Dependencies: Install the required dependencies using the provided
requirements.txt.
This project includes a Docker image that can be found on Docker Hub. You can set up and run the project using Docker without needing to manually configure a Python environment.
Pull the Docker image from Docker Hub:
$ docker pull cyrof/remotewakeserver:latestRun the Docker container with the necessary environment variables for the MAC address and broadcast IP:
$ docker run -d -p 8000:8000 --env MAC="xx-xx-xx-xx-xx-xx" --env BROADCAST="xxx.xxx.255.255 cyrof/remotewakeserver:latestReplace xx-xx-xx-xx-xx-xx with the target MAC address and xxx.xxx.255.255 with the appropriate broadcast address.
Alternatively, you can use Docker Compose to set up and run the project. Create a docker-compose.yaml file with the following content:
version: '3'
services:
wol-server:
image: cyrof/remotewakeserver:latest
ports:
- "8000:8000"
environment:
MAC: "xx-xx-xx-xx-xx-xx"
BROADCAST: "xxx.xxx.255.255"Then, run the following command to start the service:
$ docker-compose up -d For main.py to function correctly, create a .env file in the root directory of the project. The .env file must contain the MAC address of the target computer and the broadcast IP in the following format:
MAC="xx-xx-xx-xx-xx-xx"
BROADCAST="xxx.xxx.255.255"Replace xx-xx-xx-xx-xx-xx with the target MAC address and xxx.xxx.255.255 with the appropriate broadcast address.
If is recommended to use a virtual environment for managing dependencies. Follow the steps below to set up a virtual environment and install the necessary packages:
-
Create a virtual environment:
$ Python -m venv <venv-name>
-
Activate the virtual environment:
-
On Windows
$ <venv-name>\Scripts\activate
-
On macOS/Linux:
$ source <venv-name>\bin\activate
-
-
Install the dependencies:
$ pip install -r requirements.txt
If you prefer to install the dependencies globally, use:
$ pip install -r requirements.txtTo start the HTTP server, run the server.py script:
$ python server.pyThe server will start on 'localhost' at port '8000'.
Send a Get requests to the server:
$ curl http://localhost:8000The server will respond with:
Hello this is workingSend a POST request to the server:
$ curl -X POST http://localhost:8000The server will respond with:
Post is workingAdditionally, this will trigger the execution of the main.py script, which sends the Wake-on-LAN magic packet using the details specified in the .env file.
- main.py: Script to send Wake-on-LAN magic packets.
- server.py: Simple HTTP server that handles GET and POST requests.
- requirements.txt: List of dependencies required for the project.
- Dockerfile: Dockerfile to create a Docker image for the project.
- docker-compose.yaml: Docker compose configuration file.
Feel free to contribute to this project by forking this reopsitory and creating a pull request with your changes.
If you encounter any issues of have suggestions for improvements, please open an issue in the repository
This project is licensed under the MIT license.