Skip to content

Commit

Permalink
feat: add initial app to drop files
Browse files Browse the repository at this point in the history
  • Loading branch information
buildtheui committed Dec 13, 2023
1 parent 17957b1 commit 10f0828
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ go 1.21.5
require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/gofiber/fiber/v2 v2.51.0 // indirect
github.com/gofiber/template v1.8.2 // indirect
github.com/gofiber/template/html/v2 v2.0.5 // indirect
github.com/gofiber/utils v1.1.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/joho/godotenv v1.5.1 // indirect
github.com/klauspost/compress v1.16.7 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/gofiber/fiber/v2 v2.51.0 h1:JNACcZy5e2tGApWB2QrRpenTWn0fq0hkFm6k0C86gKQ=
github.com/gofiber/fiber/v2 v2.51.0/go.mod h1:xaQRZQJGqnKOQnbQw+ltvku3/h8QxvNi8o6JiJ7Ll0U=
github.com/gofiber/template v1.8.2 h1:PIv9s/7Uq6m+Fm2MDNd20pAFFKt5wWs7ZBd8iV9pWwk=
github.com/gofiber/template v1.8.2/go.mod h1:bs/2n0pSNPOkRa5VJ8zTIvedcI/lEYxzV3+YPXdBvq8=
github.com/gofiber/template/html/v2 v2.0.5 h1:BKLJ6Qr940NjntbGmpO3zVa4nFNGDCi/IfUiDB9OC20=
github.com/gofiber/template/html/v2 v2.0.5/go.mod h1:RCF14eLeQDCSUPp0IGc2wbSSDv6yt+V54XB/+Unz+LM=
github.com/gofiber/utils v1.1.0 h1:vdEBpn7AzIUJRhe+CiTOJdUcTg4Q9RK+pEa0KPbLdrM=
github.com/gofiber/utils v1.1.0/go.mod h1:poZpsnhBykfnY1Mc0KeEa6mSHrS3dV0+oBWyeQmb2e0=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
Expand Down
18 changes: 15 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
package main

import (
"log"

"github.com/buildtheui/DropMyFile/network"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/template/html/v2"
"github.com/joho/godotenv"
)

func main() {
godotenv.Load(".env")

app := fiber.New()
// Load templates
engine := html.New("./views", ".html")


app := fiber.New(fiber.Config{
Views: engine,
})

// Load extra needed files for the views like css or js
app.Static("/assets", "./views/assets")

app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
return c.Render("index", fiber.Map{})
})

network.PrintLanServerIpQr()

app.Listen(":" + network.GetServerPort())
log.Fatal(app.Listen(":" + network.GetServerPort()))
}
2 changes: 2 additions & 0 deletions network/network.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package network

import (
"fmt"
"log"
"net"
"os"
Expand All @@ -12,6 +13,7 @@ func PrintLanServerIpQr() {
myIp, _ := getLocalIp()
serverAddr := "http://" + myIp + ":" + GetServerPort()
qrterminal.Generate(serverAddr, qrterminal.L, os.Stdout)
fmt.Println("Or go to: " + serverAddr)
}

func getLocalIp() (string, error) {
Expand Down
24 changes: 24 additions & 0 deletions views/assets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* style.css */
body {
font-size: "62.5%";
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

background-color: #f4f4f4;
margin: 0;
padding: 0;
}

h1 {
color: #333;
font-family: 1.6rem;
}

form {
margin-top: 20px;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
18 changes: 18 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="/assets/style.css" />
<title>Drop my file</title>
</head>
<body>
<h1>Select your files to transfer</h1>
<form action="/upload" method="post" enctype="multipart/form-data">
<label for="file">Choose a file:</label>
<input type="file" name="file" id="file" required />
<br />
<input type="submit" value="Upload" />
</form>
</body>
</html>

0 comments on commit 10f0828

Please # to comment.