yeah (i hope i can improve this in the future maybe, but right now my logic is not in the right place)
Signed-off-by: Odyssey346 <odyssey346@disroot.org>
This commit is contained in:
parent
628bc92e66
commit
1ccdfaf28a
11
main.go
11
main.go
@ -6,24 +6,31 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"github.com/ProjectSegfault/segfautilities/otherthings"
|
"github.com/ProjectSegfault/segfautilities/otherthings"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StaticThingy struct {
|
type StaticThingy struct {
|
||||||
Port string
|
Port string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pieceof string
|
||||||
|
var shit bool
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("[Segfautilities] Starting")
|
log.Println("[Segfautilities] Starting")
|
||||||
otherthings.CheckEnv()
|
otherthings.CheckEnv()
|
||||||
|
log.Println("[HTTP] Starting server")
|
||||||
|
pieceof := os.Getenv("SEGFAUTILITIES_PORT") // I hate this
|
||||||
tmpl := template.Must(template.ParseFiles("static/index.html"))
|
tmpl := template.Must(template.ParseFiles("static/index.html"))
|
||||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
data := StaticThingy{
|
data := StaticThingy{
|
||||||
Port: "3000",
|
Port: pieceof,
|
||||||
}
|
}
|
||||||
tmpl.Execute(w, data)
|
tmpl.Execute(w, data)
|
||||||
})
|
})
|
||||||
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
|
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
io.WriteString(w, "welcome to hell")
|
io.WriteString(w, "welcome to hell")
|
||||||
})
|
})
|
||||||
http.ListenAndServe(":3000", nil)
|
log.Println("[HTTP] HTTP server is now running at " + pieceof + "!")
|
||||||
|
log.Println(http.ListenAndServe(":" + pieceof, nil))
|
||||||
}
|
}
|
Reference in New Issue
Block a user