ok commited
Signed-off-by: Odyssey <odyssey346@disroot.org>
This commit is contained in:
parent
41ecec808c
commit
588804cf62
10
main.go
10
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)
|
||||
|
14
readme.md
Normal file
14
readme.md
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user