feat: serve robots.txt, subtitle

This commit is contained in:
HeshamTB 2023-09-13 14:52:57 +03:00
parent b19919399f
commit f4a348b00f
4 changed files with 24 additions and 2 deletions

View File

@ -5,9 +5,12 @@ import "embed"
//go:embed templates/* //go:embed templates/*
var TemplatesFS embed.FS var TemplatesFS embed.FS
//go:embed static/css/* //go:embed static/css/*
var PublicFS embed.FS var PublicFS embed.FS
//go:embed assets/* //go:embed assets/*
var AssetsFS embed.FS var AssetsFS embed.FS
//go:embed static/robots.txt
var RobotsFS embed.FS

13
main.go
View File

@ -135,6 +135,19 @@ func main() {
handler.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(PublicFS)))) handler.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(PublicFS))))
handler.Handle("/assets/", http.FileServer(http.FS(AssetsFS))) handler.Handle("/assets/", http.FileServer(http.FS(AssetsFS)))
handler.HandleFunc(
"/robots.txt",
func(w http.ResponseWriter, r *http.Request) {
robotsFile, err := RobotsFS.ReadFile("static/robots.txt")
if err != nil {
log.Println(err.Error())
w.WriteHeader(500)
return
}
w.Write(robotsFile)
},
)
handler.HandleFunc( handler.HandleFunc(
"/download", "/download",
func(w http.ResponseWriter, r *http.Request) { func(w http.ResponseWriter, r *http.Request) {

1
static/robots.txt Normal file
View File

@ -0,0 +1 @@
# Go carzy

View File

@ -11,7 +11,12 @@
<title>Viddle your fiddle</title> <title>Viddle your fiddle</title>
</head> </head>
<main class="container"> <main class="container">
<h1>Viddle your fiddle</h1> <div class="headings">
<h3>
Viddle your fiddle
<h4>Grab your videos for safe keeping!</h4>
</h3>
</div>
<form hx-post="/download" hx-target="#get-btn" hx-swap="outerHTML" hx-indicator="#progress"> <form hx-post="/download" hx-target="#get-btn" hx-swap="outerHTML" hx-indicator="#progress">
<div class="grid"> <div class="grid">
<div hx-target="this" hx-swap="outerHTML"> <div hx-target="this" hx-swap="outerHTML">