diff --git a/lts.go b/lts.go index bf9058c..b0e5e2d 100644 --- a/lts.go +++ b/lts.go @@ -117,10 +117,6 @@ func handleUpload(w http.ResponseWriter, r *http.Request) { } defer file.Close() - fmt.Fprintf(w, "Uploaded file: %s\n", handler.Filename) - fmt.Fprintf(w, "File size: %s\n", byteCountSI(handler.Size)) - fmt.Fprintf(w, "Link: ") - dst, err := createFile(storePath, handler.Filename) if err != nil { http.Error(w, "Could not save file", http.StatusInternalServerError) @@ -131,6 +127,10 @@ func handleUpload(w http.ResponseWriter, r *http.Request) { if _, err := dst.ReadFrom(file); err != nil { http.Error(w, "Error saving file", http.StatusInternalServerError) } + + fmt.Fprintf(w, "Uploaded file: %s\n", handler.Filename) + fmt.Fprintf(w, "File size: %s\n", byteCountSI(handler.Size)) + fmt.Fprintf(w, "Link: %s", fmt.Sprintf("%s/%s", listener.Addr().String(), dst.Name())) } func handleHome(w http.ResponseWriter, r *http.Request) { @@ -248,10 +248,11 @@ func main() { http.Handle("/etc/", http.FileServerFS(etc)) http.Handle("/store/", http.StripPrefix("/store/", http.FileServer(http.Dir(storePath)))) - listener, err := net.Listen("tcp", LISTEN_ADDR) + listener_tcp, err := net.Listen("tcp", LISTEN_ADDR) if err != nil { log.Fatal("Error starting server: ", err) } + listener = listener_tcp log.Printf("Listening on %s\n", listener.Addr().String())