initial commit
This commit is contained in:
48
main.go
Normal file
48
main.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"html/template"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"path/filepath"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func pageHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
path := strings.Trim(r.URL.Path, "/")
|
||||||
|
if path == "" {
|
||||||
|
path = "home"
|
||||||
|
}
|
||||||
|
|
||||||
|
exePath, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
exeDir := filepath.Dir(exePath)
|
||||||
|
templateDir := filepath.Join(exeDir, "templates")
|
||||||
|
|
||||||
|
tmpl, err := template.ParseFiles(
|
||||||
|
filepath.Join(templateDir, "layout.html"),
|
||||||
|
filepath.Join(templateDir, "header.html"),
|
||||||
|
filepath.Join(templateDir, "footer.html"),
|
||||||
|
filepath.Join(templateDir, path+".html"),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tmpl.ExecuteTemplate(w, "layout", nil)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
http.HandleFunc("/", pageHandler)
|
||||||
|
|
||||||
|
log.Println("Server running at http://localhost:14888")
|
||||||
|
log.Fatal(http.ListenAndServe(":14888", nil))
|
||||||
|
}
|
109
static/style.css
Normal file
109
static/style.css
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
html {
|
||||||
|
background: #5E0084;
|
||||||
|
padding-bottom: 400px;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
max-width: 750px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-top: 30px;
|
||||||
|
background: #002F5E;
|
||||||
|
color: #eee;
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 5px;
|
||||||
|
border-color: #123;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
main {
|
||||||
|
padding: 1em ;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1,h2,h3,h4 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 48px;
|
||||||
|
text-shadow: 3px 0 black, 3px 3px black, 0 3px black;
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.links {
|
||||||
|
display: list-item;
|
||||||
|
list-style: none;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 48pt;
|
||||||
|
margin: 0;
|
||||||
|
display: block;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
img .links {
|
||||||
|
height: 64px;
|
||||||
|
width: 64px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
color: #00bbdd ;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
color: #00aabb ;
|
||||||
|
}
|
||||||
|
|
||||||
|
a { color: lightblue; }
|
||||||
|
|
||||||
|
.image {
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr { max-width: 150px ; padding: 10px }
|
||||||
|
|
||||||
|
p img, li img, h1 img, h2 img, h3 img, h4 img {
|
||||||
|
max-height: 1em;
|
||||||
|
max-width: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
border: 1px solid lime ;
|
||||||
|
border-radius: 20px ;
|
||||||
|
padding: 1em ;
|
||||||
|
margin: 1em ;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
border-radius: 5px ;
|
||||||
|
overflow-wrap: break-word ;
|
||||||
|
font-size: x-small;
|
||||||
|
}
|
||||||
|
|
||||||
|
code:not(pre code) {
|
||||||
|
color: lime;
|
||||||
|
}
|
||||||
|
|
||||||
|
aside {
|
||||||
|
color: gray ;
|
||||||
|
font-style: italic ;
|
||||||
|
font-size: small ;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
text-align: center ;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
padding-left: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal {
|
||||||
|
align: center ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.normal img {
|
||||||
|
margin: auto ;
|
||||||
|
max-width: 90% ;
|
||||||
|
max-height: 400px ;
|
||||||
|
display: block ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
4
templates/about.html
Normal file
4
templates/about.html
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{{define "content"}}
|
||||||
|
<h1>abouaboutt</h1>
|
||||||
|
<p>im supoer cool</p>
|
||||||
|
{{end}}
|
7
templates/footer.html
Normal file
7
templates/footer.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<footer>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
Monero XMR: <code>44KiSSaf5h7MGd3GqAaNZc45DdwC7q9BmCtsZ9knfsCNj7PyipHfBvBUZVHiBUU8dMJJ82MfPBZdzVugUs7BnANT6SUyDsN</code>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</footer>
|
6
templates/header.html
Normal file
6
templates/header.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<header>
|
||||||
|
<p>
|
||||||
|
<a href="/" target="_top"><b> Home</b></a><b> |
|
||||||
|
<a href="/about" target="_top">About</a></b>
|
||||||
|
</p>
|
||||||
|
</header>
|
5
templates/home.html
Normal file
5
templates/home.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{{define "content"}}
|
||||||
|
<h1>Kisu's homepage</h1>
|
||||||
|
<p>Resist Resist Resist</p>
|
||||||
|
|
||||||
|
{{end}}
|
19
templates/layout.html
Normal file
19
templates/layout.html
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{{define "layout"}}
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="stylesheet" href="/static/style.css">
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{{template "header.html" .}}
|
||||||
|
|
||||||
|
<main>
|
||||||
|
{{block "content" .}} {{end}}
|
||||||
|
{{template "footer.html" .}}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{{end}}
|
Reference in New Issue
Block a user