260702_023719

This commit is contained in:
Maciej J. Bowszys 2026-07-02 02:37:19 +02:00
parent a2d00a212d
commit 01bb14e465
5 changed files with 61 additions and 2 deletions

View File

@ -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))
}

1
website/static/mani.json Normal file
View File

@ -0,0 +1 @@
aabbcc

View File

@ -0,0 +1 @@
dis ys desd

View File

@ -0,0 +1 @@
aaaabb

View File

@ -0,0 +1,7 @@
<h1 id="abc">Ttesttt</h1>
<h1>Ttesttt</h1>
<script>
window.onload = () => {
document.getElementById("abc").innerHTML = window.location.pathname.split("/").at(-1);
};
</script>