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

49 lines
1.3 KiB
Go
Raw Normal View History

package main
import (
"net/http"
"html/template"
"io"
"log"
"github.com/ProjectSegfault/segfautilities/otherthings"
"os"
"github.com/ProjectSegfault/segfautilities/api"
)
type StaticThingy struct {
Port string
2022-07-29 18:11:45 +05:30
HCaptchaSiteKey string
}
var port string
var shit bool
func main() {
log.Println("[Segfautilities] Starting")
otherthings.CheckEnv()
log.Println("[HTTP] Starting server")
port := os.Getenv("SEGFAUTILITIES_PORT")
hcaptcha_site_key := os.Getenv("HCAPTCHA_SITE_KEY")
tmpl := template.Must(template.ParseFiles("static/index.html"))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
data := StaticThingy{
Port: 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{
2022-07-29 18:11:45 +05:30
HCaptchaSiteKey: hcaptcha_site_key,
2022-07-29 18:05:19 +05:30
}
tmpl_form.Execute(w, data)
})
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "welcome to hell")
})
api.Form()
log.Println("[HTTP] HTTP server is now running at " + port + "!")
log.Println(http.ListenAndServe(":" + port, nil))
}