A powerful, standalone static file server written in Go, featuring virtual hosting, automatic hosts file management, a built-in JSON database API, and system tray integration.
- Virtual Hosting: Serve different folders for different domains (e.g.,
myserver.local,docs.local). - Auto-Hosts Configuration: Automatically adds configured domains to your Windows
hostsfile (requires Administrator privileges). - JSON Database API: A built-in REST API to read and write JSON files, enabling backend-less frontend development.
- System Tray Integration: Runs silently in the background with a system tray icon and "Quit" option.
- Auto-Open Browser: Optionally opens your default browser to the configured sites on startup.
- Zero-Config Deployment: compiles to a single
start.exe(plusconfig.xml).
- Go (if building from source)
- Windows OS (for hosts file automation and system tray)
To build the project effectively, you need to create two executables: one for the main server (background) and one for the stop utility.
-
Build the Server (Headless/Background)
go build -ldflags "-H=windowsgui" -o start.exe main.go icon.go
-
Build the Stop Utility
go build -o stop.exe stop.go
Server behavior is controlled via config.xml in the same directory.
<Config>
<Port>9000</Port>
<Sites>
<Site>
<Domain>myserver.local</Domain>
<Path>.</Path>
<AutoOpen>true</AutoOpen>
</Site>
<Site>
<Domain>docs.local</Domain>
<Path>./docs</Path>
<!-- AutoOpen defaults to false if omitted -->
</Site>
</Sites>
</Config>- Port: The HTTP port to listen on.
- Sites: List of site configurations.
- Domain: The hostname to listen for.
- Path: The local directory (or file) to serve for this domain.
- AutoOpen: If
true, opens this URL in the browser on startup.
-
Start the Server: Double-click
start.exe.- It will appear in your System Tray.
- If running as Administrator, it will update
C:\Windows\System32\drivers\etc\hostsautomatically. - Logs are written to
server.log.
-
Stop the Server:
- Right-click the System Tray icon and select Quit.
- OR run
stop.exe.
The server exposes a simple API to read/write JSON files located in the db/ directory.
-
GET
/api/db/users- Returns the content of
db/users.json. - Returns
{}if the file does not exist.
- Returns the content of
-
POST
/api/db/users- Overwrites
db/users.jsonwith the request body (JSON). - returns
{"status": "ok"}on success.
- Overwrites
// Read
fetch('/api/db/guestbook')
.then(res => res.json())
.then(data => console.log(data));
// Write
fetch('/api/db/guestbook', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ entries: [...] })
});