4 Commits
Author SHA1 Message Date
iamdoubz 3e4cf727a6 Add more requirements for python 2025-05-21 14:02:36 -05:00
iamdoubz e3af068661 Add .env steps to python section 2025-05-21 13:59:41 -05:00
iamdoubz 3c802467bc Add env example 2025-05-21 13:53:16 -05:00
iamdoubz 7ff000dc6f Read HOST and PORT from .env file 2025-05-21 13:51:41 -05:00
3 changed files with 16 additions and 8 deletions
+8 -6
View File
@@ -8,7 +8,7 @@ A simple program that integrates with Windows Services to retrieve the hostname
- At least python3.10 or higher (may work on lower versions but untested)
- python and pip are in your environmental variables (python --version)
- `pip install pywin32`
- `pip install pywin32 python-dotenv`
### Go
@@ -20,9 +20,11 @@ A simple program that integrates with Windows Services to retrieve the hostname
### Python
1. Download `hostname-service.py` file
2. Open terminal as admin
3. `python hostname_service.py run`
1. Download `hostname-service.py` and `env.txt` files
2. Copy `env.txt` to `.env`
3. Edit `.env` file to match your requirements
4. Open terminal as admin
5. `python hostname_service.py run`
### Go
@@ -56,11 +58,11 @@ Use `python hostname_service.py` and one of the following option names.
### Go
Use `./hostname_service.exe` and one of the following option names.
Use `go run hostname_service.go` and one of the following option names.
| Option Name | Description |
| :---: | ---: |
| | Start the server in standalone mode |
| run | Start the server in standalone mode |
| install | Create a Windows Service entry |
| start | Start the Windows service |
| stop | Stop the Windows service |
+2
View File
@@ -0,0 +1,2 @@
HOST=127.0.0.1
PORT=8999
+6 -2
View File
@@ -1,4 +1,5 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
from dotenv import load_dotenv
import socket
import json
import threading
@@ -10,8 +11,11 @@ import servicemanager
import os
import sys
HOST = '0.0.0.0'
PORT = 8999
# Load environment variables from .env file
load_dotenv()
HOST = os.getenv("HOST", "0.0.0.0")
PORT = int(os.getenv("PORT", 8999))
LOG_FILE = os.path.join(os.path.dirname(__file__), 'hostname_service.log')
logging.basicConfig(