diff options
| -rw-r--r-- | index.html | 28 | ||||
| -rw-r--r-- | main.go | 13 |
2 files changed, 34 insertions, 7 deletions
diff --git a/index.html b/index.html new file mode 100644 index 0000000..2869c13 --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<html lang="en"> + <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>UxU</title> + <style> + code { + font-family: 'Fira Code', 'JetBrains Mono', Consolas, Monaco, monospace; + font-size: 1.1rem; + background: #c2c2c2; + padding: 0; + } + </style> + </head> + <body> + <h2>Welcome to UxU</h2> + + <p>Yes! UxU is a File Hosting service, but not in it's traditional sense. There is no Upload Button. + You need to move to the cultured way of doing it -- using curl.</p> + <br><br> + <code>curl -X POST -F "file=@file.png"</code> + <br><br>and the reponse will be a link with your Filename (sanitized ofcourse) + + <script src="index.js"></script> + </body> +</html> @@ -3,14 +3,11 @@ package main import ( "net/http" "fmt" + "log" "path/filepath" "github.com/gin-gonic/gin" ) -func index(c *gin.Context){ - -} - func main(){ router := gin.Default() @@ -21,15 +18,17 @@ func main(){ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } - fmt.Println(file.Filename) + log.Println(file.Filename) dst := filepath.Join("./files/", filepath.Base(file.Filename)) c.SaveUploadedFile(file, dst) - c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!\n", file.Filename)) + c.String(http.StatusOK, fmt.Sprintf("%s/%s\n", domain , file.Filename)) }) + router.LoadHTMLFiles("index.html") + router.GET("/", func(c *gin.Context) { - c.String(http.StatusOK, fmt.Sprintf("HTTP WORKS TOO!")) + c.HTML(http.StatusOK, "index.html", gin.H{}) }) var safeFS http.FileSystem = http.Dir("./files") |
