From 588804cf62003cbb23c73dc36d209886bd10a1d7 Mon Sep 17 00:00:00 2001 From: Odyssey Date: Sat, 7 Jan 2023 18:16:35 +0100 Subject: [PATCH] ok commited Signed-off-by: Odyssey --- main.go | 10 +++++++++- readme.md | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 readme.md diff --git a/main.go b/main.go index 7d42ccd..38da3f2 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,8 @@ import ( "github.com/gofiber/fiber/v2" log "github.com/sirupsen/logrus" + + "runtime" ) // publapi is a simple API for Project Segfault's public shared server (pubnix). @@ -22,8 +24,14 @@ func main() { }) app.Get("/online", func(c *fiber.Ctx) error { + if runtime.GOOS == "windows" { + return c.JSON(fiber.Map{ + "message": "/online is not supported on Windows", + "status": c.Response().StatusCode(), + }) + } // Get the number of users online - out, err := exec.Command("users | wc -l").Output() + out, err := exec.Command("bash", "-c", "users | wc -l").Output() if err != nil { log.Error(err) return c.SendStatus(fiber.StatusInternalServerError) diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..99dc0f4 --- /dev/null +++ b/readme.md @@ -0,0 +1,14 @@ +# Publapi + +Publapi is a simple API for Project Segfault's public shared system (pubnix). + +## Install +An installation of Go 1.19 or higher is required. +``` +git clone https://github.com/ProjectSegfault/publapi +go mod download +go build +./publapi +``` + +By default it listens to port 3000 on 127.0.0.1. You can change the port with the environment variable PUBLAPI_PORT. \ No newline at end of file