save
This commit is contained in:
@@ -2,13 +2,24 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
"lash"
|
"lash"
|
||||||
"lash/internal/app"
|
"lash/internal/app"
|
||||||
"lash/internal/errx"
|
"lash/internal/errx"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var versionFlag = flag.Bool("version", false, "Print out version and exit.")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if *versionFlag {
|
||||||
|
fmt.Print("lash/vxc v", lash.Version)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
srv := app.New()
|
srv := app.New()
|
||||||
|
|
||||||
errx.Log("Your token is \033[1;92m%s\033[0m", lash.Token)
|
errx.Log("Your token is \033[1;92m%s\033[0m", lash.Token)
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"lash"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"lash"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ShareData struct {
|
type ShareData struct {
|
||||||
@@ -11,7 +12,10 @@ type ShareData struct {
|
|||||||
FileName string
|
FileName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h ShareData) Handler(w http.ResponseWriter, r *http.Request) {
|
func (h *ShareData) Handler(w http.ResponseWriter, r *http.Request) {
|
||||||
tmpl := template.Must(template.ParseFS(lash.Templates, "share.html"))
|
tmpl := template.Must(template.ParseFS(lash.Templates, "templates/share.html"))
|
||||||
tmpl.ExecuteTemplate(w, "share.html", h)
|
|
||||||
|
if err := tmpl.ExecuteTemplate(w, "share.html", h); err != nil {
|
||||||
|
http.Error(w, "template render error: "+err.Error(), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
lash.go
7
lash.go
@@ -3,13 +3,14 @@ package lash
|
|||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
// "github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed templates/*
|
//go:embed templates/*.html
|
||||||
var Templates embed.FS
|
var Templates embed.FS
|
||||||
|
|
||||||
//go:embed version
|
//go:embed version
|
||||||
var Version string
|
var Version string
|
||||||
|
|
||||||
var Token string = uuid.New().String()
|
// var Token string = uuid.New().String()
|
||||||
|
var Token string = "foo"
|
||||||
|
|||||||
@@ -7,19 +7,13 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<form id="tform" action="localpage.html" method="POST">
|
|
||||||
<input name="token" id="token" placeholder="Enter token">
|
|
||||||
<button type="submit">Go</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
await fetch('/api/receive-token', {
|
await fetch('/api/receive-token', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ token: USER_TOKEN })
|
body: JSON.stringify({ token: "foo" })
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user