Pretty html, etc.
Anirudh Oppiliappan x@icyphox.sh
Mon, 07 Jun 2021 09:59:31 +0530
3 files changed,
44 insertions(+),
3 deletions(-)
M
index.html
→
index.html
@@ -4,12 +4,21 @@ <head>
<meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> - <title>Document</title> + <title>fsrv</title> + <link rel="icon" type="image/png" sizes="16x16" href="https://icyphox.sh/favicon.png"> </head> + <style> + body { + max-width: 640px; + padding: 0 10px; + margin: 40px auto; + } + </style> <body> + <h1>fsrv</h1> <form enctype="multipart/form-data" - action="http://localhost:4040" + action="https://x.icyphox.sh/" method="post" > <p>file:</p>
M
main.go
→
main.go
@@ -18,6 +18,7 @@ port string
namelen int key string storepath string + index string } func randName(n int) string {@@ -62,7 +63,7 @@
fileUrl := s.url + "/" + newFile fmt.Fprintf(w, "%v", fileUrl) case "GET": - http.ServeFile(w, r, "index.html") + http.ServeFile(w, r, s.index) default: fmt.Fprintf(w, "unsupported method") }@@ -74,6 +75,7 @@ flag.StringVar(&s.port, "port", "9393", "port to listen on")
flag.StringVar(&s.storepath, "storepath", "uploads", "path to store uploaded files") flag.IntVar(&s.namelen, "namelen", 5, "length of random filename") flag.StringVar(&s.key, "key", "secret", "secret key; generate this yourself") + flag.StringVar(&s.index, "index", "index.html", "path to index html file") flag.Parse() }
A
readme
@@ -0,0 +1,30 @@
+FSRV + +Filehost server for https://x.icyphox.sh. + + +(NON) FEATURES + +· Single-user +· Only handles file upload. Serving is left to the reverse proxy. +· Bring your own index.html (-index flag) +· Requires a key to upload. Change the default! + + +USAGE + + Usage of ./fsrv: + -index string + path to index html file (default "index.html") + -key string + secret key; generate this yourself (default "secret") + -namelen int + length of random filename (default 5) + -port string + port to listen on (default "9393") + -storepath string + path to store uploaded files (default "uploads") + -url string + url for fsrv to serve files (default "localhost") + +Sample index.html is provided. Edit as required.