diff --git a/moira_db.go b/moira_db.go index 751852a..77a067b 100644 --- a/moira_db.go +++ b/moira_db.go @@ -1,8 +1,57 @@ package main -import "fmt" +import ( + //"fmt" + "html/template" + "log" + "net/http" + "os" + //"regexp" + //"strings" + //"maps" + //"slices" +) +var templates *template.Template = template.New("") + + +func hdlr_renderHTML(in_leaderPath string, in_fileName string) http.HandlerFunc{ + return func (resp http.ResponseWriter, req *http.Request){ + err := templates.ExecuteTemplate(resp, in_fileName, nil) // resp, in_fileName, contextObj) + + if(err != nil){ + http.Error(resp, err.Error(), http.StatusInternalServerError) + } + } +} + func main(){ - fmt.Println("Welcome to moira_db!"); + http.Handle("/", http.FileServer(http.Dir("./website/static"))) + + template_renders := map[string]string { + "/film/view/": "film/index.html", + "/film/edit/": "index.html", + "/list/view/": "index.html", + "/list/edit/": "index.html", + "/group/view/": "index.html", + "/group/edit/": "index.html", + } + + for _,i_file := range template_renders{ + text, err := os.ReadFile("./website/templates/" + i_file) + if(err != nil){ + panic(err) + } + + templates.New(i_file).Parse(string(text)) + } + + for i_path,i_file := range template_renders{ + http.HandleFunc(i_path, hdlr_renderHTML(i_path, i_file)) + } + + + //fmt.Println("Welcome to moira_db!"); + log.Fatal(http.ListenAndServe(":8000", nil)) } diff --git a/website/static/mani.json b/website/static/mani.json new file mode 100644 index 0000000..a89157f --- /dev/null +++ b/website/static/mani.json @@ -0,0 +1 @@ +aabbcc diff --git a/website/static/somefile.txt b/website/static/somefile.txt new file mode 100644 index 0000000..380663a --- /dev/null +++ b/website/static/somefile.txt @@ -0,0 +1 @@ +dis ys desd diff --git a/website/templates/film/index.html b/website/templates/film/index.html new file mode 100644 index 0000000..075b8e8 --- /dev/null +++ b/website/templates/film/index.html @@ -0,0 +1 @@ +aaaabb diff --git a/website/templates/index.html b/website/templates/index.html new file mode 100644 index 0000000..8870f2f --- /dev/null +++ b/website/templates/index.html @@ -0,0 +1,7 @@ +

Ttesttt

+

Ttesttt

+