This repository has been archived on 2022-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
Segfautils/main.go
Midou36O 16ea5c3138
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Fix the go error.
2022-09-18 00:40:46 +01:00

41 lines
867 B
Go

package main
import (
"io"
"log"
"net/http"
"text/template"
"github.com/ProjectSegfault/segfautils/api"
"github.com/ProjectSegfault/segfautils/config"
"github.com/ProjectSegfault/segfautils/utils"
)
type StaticThingy struct {
Port string
}
func main() {
log.Println("[Segfautils] Starting")
utils.CheckConfig()
tmpl := template.Must(template.ParseFiles("static/index.html"))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
data := StaticThingy{
Port: config.Port(),
}
tmpl.Execute(w, data)
})
log.Println("[HTTP] Starting server")
api.CheckAnn()
api.FormCheck()
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "welcome to hell")
})
log.Println("[HTTP] HTTP server is now running at " + config.Port() + "!")
log.Println(http.ListenAndServe(":"+config.Port(), nil))
}