2022-07-20 14:27:12 +05:30
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-08-02 14:11:17 +05:30
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
2022-08-15 00:36:00 +05:30
|
|
|
"text/template"
|
2022-08-02 14:11:17 +05:30
|
|
|
|
|
|
|
"github.com/ProjectSegfault/segfautils/api"
|
2022-08-15 00:36:00 +05:30
|
|
|
"github.com/ProjectSegfault/segfautils/config"
|
2022-08-04 01:07:12 +05:30
|
|
|
"github.com/ProjectSegfault/segfautils/utils"
|
2022-07-20 14:27:12 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
type StaticThingy struct {
|
2022-08-02 14:11:17 +05:30
|
|
|
Port string
|
|
|
|
HCaptchaSiteKey string
|
2022-07-20 14:27:12 +05:30
|
|
|
}
|
|
|
|
|
2022-07-29 01:07:41 +05:30
|
|
|
var port string
|
2022-07-23 01:33:34 +05:30
|
|
|
var shit bool
|
|
|
|
|
2022-07-20 14:27:12 +05:30
|
|
|
func main() {
|
2022-08-02 14:11:17 +05:30
|
|
|
log.Println("[Segfautils] Starting")
|
2022-08-15 00:36:00 +05:30
|
|
|
utils.CheckConfig()
|
2022-08-02 14:11:17 +05:30
|
|
|
log.Println("[HTTP] Starting server")
|
2022-08-15 00:36:00 +05:30
|
|
|
hcaptcha_site_key := config.HCaptchaSiteKey()
|
2022-07-20 14:27:12 +05:30
|
|
|
tmpl := template.Must(template.ParseFiles("static/index.html"))
|
2022-08-02 14:11:17 +05:30
|
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
data := StaticThingy{
|
2022-08-15 00:36:00 +05:30
|
|
|
Port: config.Port(),
|
2022-08-02 14:11:17 +05:30
|
|
|
}
|
|
|
|
tmpl.Execute(w, data)
|
|
|
|
})
|
2022-07-29 18:05:19 +05:30
|
|
|
|
|
|
|
tmpl_form := template.Must(template.ParseFiles("static/form.html"))
|
2022-08-02 14:11:17 +05:30
|
|
|
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
|
|
|
|
2022-07-20 14:27:12 +05:30
|
|
|
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
|
2022-08-02 14:11:17 +05:30
|
|
|
io.WriteString(w, "welcome to hell")
|
|
|
|
})
|
2022-08-04 01:07:12 +05:30
|
|
|
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()
|
2022-08-02 14:11:17 +05:30
|
|
|
api.Form()
|
2022-09-18 02:20:55 +05:30
|
|
|
api.CheckAnn()
|
2022-08-15 00:36:00 +05:30
|
|
|
log.Println("[HTTP] HTTP server is now running at " + config.Port() + "!")
|
|
|
|
log.Println(http.ListenAndServe(":"+config.Port(), nil))
|
2022-08-02 14:11:17 +05:30
|
|
|
}
|