Compare commits
2 Commits
3c0f1a046c
...
6da1bb9fc1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6da1bb9fc1 | ||
|
|
fb7d0ee80d |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
lash
|
||||
12
Makefile
Normal file
12
Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
GO?= go
|
||||
|
||||
.PHONY: build lint
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
$(GO) build -o lash ./cmd/lash/
|
||||
|
||||
lint:
|
||||
$(GO) fmt ./...
|
||||
$(GO) vet ./...
|
||||
@@ -2,13 +2,24 @@ package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"lash"
|
||||
"lash/internal/app"
|
||||
"lash/internal/errx"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var versionFlag = flag.Bool("version", false, "Print out version and exit.")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if *versionFlag {
|
||||
fmt.Print("lash/vxc v", lash.Version)
|
||||
return
|
||||
}
|
||||
|
||||
srv := app.New()
|
||||
|
||||
errx.Log("Your token is \033[1;92m%s\033[0m", lash.Token)
|
||||
|
||||
@@ -2,6 +2,6 @@ package errx
|
||||
|
||||
import "fmt"
|
||||
|
||||
func Log(msg string, k... any) {
|
||||
fmt.Printf("lash: " + msg + "\n", k...)
|
||||
func Log(msg string, k ...any) {
|
||||
fmt.Printf("lash: "+msg+"\n", k...)
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ package handlers
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"lash"
|
||||
"net/http"
|
||||
|
||||
"lash"
|
||||
)
|
||||
|
||||
type ShareData struct {
|
||||
@@ -11,7 +12,10 @@ type ShareData struct {
|
||||
FileName string
|
||||
}
|
||||
|
||||
func (h ShareData) Handler(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl := template.Must(template.ParseFS(lash.Templates, "share.html"))
|
||||
tmpl.ExecuteTemplate(w, "share.html", h)
|
||||
func (h *ShareData) Handler(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl := template.Must(template.ParseFS(lash.Templates, "templates/share.html"))
|
||||
|
||||
if err := tmpl.ExecuteTemplate(w, "share.html", h); err != nil {
|
||||
http.Error(w, "template render error: "+err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
11
lash.go
11
lash.go
@@ -1,11 +1,16 @@
|
||||
package lash
|
||||
|
||||
import "embed"
|
||||
import (
|
||||
"embed"
|
||||
|
||||
//go:embed templates/*
|
||||
// "github.com/google/uuid"
|
||||
)
|
||||
|
||||
//go:embed templates/*.html
|
||||
var Templates embed.FS
|
||||
|
||||
//go:embed version
|
||||
var Version string
|
||||
|
||||
var Token string = "SICK-COOL-TOKEN"
|
||||
// var Token string = uuid.New().String()
|
||||
var Token string = "foo"
|
||||
|
||||
@@ -7,19 +7,13 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<form id="tform" action="localpage.html" method="POST">
|
||||
<input name="token" id="token" placeholder="Enter token">
|
||||
<button type="submit">Go</button>
|
||||
</form>
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
await fetch('/api/receive-token', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ token: USER_TOKEN })
|
||||
body: JSON.stringify({ token: "foo" })
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user