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

55 lines
1.3 KiB
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
HCaptchaSiteKey string
}
var port string
var shit bool
func main() {
log.Println("[Segfautils] Starting")
utils.CheckConfig()
log.Println("[HTTP] Starting server")
hcaptcha_site_key := config.HCaptchaSiteKey()
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
tmpl_form := template.Must(template.ParseFiles("static/form.html"))
http.HandleFunc("/form/", func(w http.ResponseWriter, r *http.Request) {
data := StaticThingy{
HCaptchaSiteKey: hcaptcha_site_key,
}
tmpl_form.Execute(w, data)
})
2022-07-29 18:05:19 +05:30
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "welcome to hell")
})
http.HandleFunc("/announcements", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "static/announcements.html")
})
2022-09-18 02:20:55 +05:30
api.Settings()
api.Form()
2022-09-18 02:20:55 +05:30
api.CheckAnn()
log.Println("[HTTP] HTTP server is now running at " + config.Port() + "!")
log.Println(http.ListenAndServe(":"+config.Port(), nil))
}