initial commit

This commit is contained in:
DeveloperDurp 2024-07-17 05:09:36 -05:00
parent 24afc01911
commit 035a813154
7 changed files with 80 additions and 0 deletions

8
.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

9
.idea/durpweb.iml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/durpweb.iml" filepath="$PROJECT_DIR$/.idea/durpweb.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module gitlab.com/developerdurp/durpweb
go 1.22.0

14
index.html Normal file
View file

@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
</head>
<body>
<h1>Go and HTMX</h1>
<h2>{{.Message}}</h2>
<button hx-get="/time" hx-target="#time">Get Current Time</button>
<h2 id="time">Shows Current Time</h2>
</body>
</html>

32
main.go Normal file
View file

@ -0,0 +1,32 @@
package main
import (
"fmt"
"html/template"
"net/http"
"time"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
tmpl, err := template.ParseFiles("index.html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
data := struct {
Message string
}{
Message: "Hello World",
}
tmpl.Execute(w, data)
})
http.HandleFunc("/time", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Current Time: " + time.Now().Format(time.RFC1123)))
})
fmt.Println("Started http server on port :8080")
http.ListenAndServe(":8080", nil)
}