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

41 lines
867 B
Go
Raw Normal View History

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)
})
2022-07-29 18:05:19 +05:30
log.Println("[HTTP] Starting server")
2022-09-18 22:14:37 +05:30
api.AnnCheck()
api.FormCheck()
2022-07-29 18:05:19 +05:30
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))
}