Compare commits
No commits in common. "fe522cbee3e0e07dbb2fb08b12e2c03bcfa6dc90" and "196563a95123e64f8a2cb49d158cf10078fef7e5" have entirely different histories.
fe522cbee3
...
196563a951
|
@ -1,25 +0,0 @@
|
||||||
name: Go audit
|
|
||||||
run-name: ${{ gitea.actor }} pulled to main! 🚀
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [main]
|
|
||||||
jobs:
|
|
||||||
audit:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '>=1.22.0'
|
|
||||||
|
|
||||||
- name: Verify dependencies
|
|
||||||
run: go mod verify
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: go build -v ./...
|
|
||||||
|
|
||||||
- name: Run go vet
|
|
||||||
run: go vet ./...
|
|
|
@ -1,51 +0,0 @@
|
||||||
# This is an example .goreleaser.yml file with some sensible defaults.
|
|
||||||
# Make sure to check the documentation at https://goreleaser.com
|
|
||||||
|
|
||||||
# The lines below are called `modelines`. See `:help modeline`
|
|
||||||
# Feel free to remove those if you don't want/need to use them.
|
|
||||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
|
||||||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
|
||||||
|
|
||||||
version: 1
|
|
||||||
|
|
||||||
before:
|
|
||||||
hooks:
|
|
||||||
# You may remove this if you don't use go modules.
|
|
||||||
- go mod tidy
|
|
||||||
# you may remove this if you don't need go generate
|
|
||||||
- go generate ./...
|
|
||||||
|
|
||||||
gitea_urls:
|
|
||||||
api: https://git.bulgariu.xyz/api/v1
|
|
||||||
download: https://git.bulgariu.xyz
|
|
||||||
|
|
||||||
builds:
|
|
||||||
- env:
|
|
||||||
- CGO_ENABLED=0
|
|
||||||
goos:
|
|
||||||
- linux
|
|
||||||
- windows
|
|
||||||
goarch:
|
|
||||||
- amd64
|
|
||||||
|
|
||||||
archives:
|
|
||||||
- format: tar.gz
|
|
||||||
# this name template makes the OS and Arch compatible with the results of `uname`.
|
|
||||||
name_template: >-
|
|
||||||
{{ .ProjectName }}_
|
|
||||||
{{- title .Os }}_
|
|
||||||
{{- if eq .Arch "amd64" }}x86_64
|
|
||||||
{{- else if eq .Arch "386" }}i386
|
|
||||||
{{- else }}{{ .Arch }}{{ end }}
|
|
||||||
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
|
||||||
# use zip for windows archives
|
|
||||||
format_overrides:
|
|
||||||
- goos: windows
|
|
||||||
format: zip
|
|
||||||
|
|
||||||
changelog:
|
|
||||||
sort: asc
|
|
||||||
filters:
|
|
||||||
exclude:
|
|
||||||
- "^docs:"
|
|
||||||
- "^test:"
|
|
|
@ -1,9 +1,3 @@
|
||||||
# uploader
|
# uploader
|
||||||
|
|
||||||
Small HTTP server that lets users easily upload files to your computer.
|
Small HTTP server that lets users easily upload files to your computer.
|
||||||
|
|
||||||
## Usage:
|
|
||||||
```
|
|
||||||
./uploader
|
|
||||||
```
|
|
||||||
Visit http://localhost:8080/
|
|
|
@ -16,21 +16,7 @@
|
||||||
<button id="but">
|
<button id="but">
|
||||||
Upload
|
Upload
|
||||||
</button>
|
</button>
|
||||||
<progress id="progress" value="0" max="100">Upload progress:</progress>
|
|
||||||
</form>
|
</form>
|
||||||
<script>
|
|
||||||
htmx.on('#form', 'htmx:xhr:progress', function(evt) {
|
|
||||||
htmx.find('#progress').setAttribute('value', evt.detail.loaded/evt.detail.total * 100)
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p class="centered">
|
|
||||||
<!-- <img src="https://bulgariu.xyz/avatar.gif" alt="" width=200px height=200px > -->
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<!-- <footer> -->
|
|
||||||
<!-- Licensed under the GPL v3.0 -->
|
|
||||||
<!-- </footer> -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,16 +7,7 @@
|
||||||
border: 2px black solid;
|
border: 2px black solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
.centered {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
text-align: center;
|
|
||||||
border: 2px solid #ff6e00;
|
|
||||||
border-radius: 50%;
|
|
||||||
padding: 1%;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
button {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
|
@ -47,28 +38,9 @@ form {
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #ff6e00;
|
color: #ff6e00;
|
||||||
text-decoration: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a:hover {
|
a:hover {}
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
progress::-moz-progress-bar {
|
|
||||||
background-color: #ff6e00;
|
|
||||||
}
|
|
||||||
|
|
||||||
progress::-webkit-progress-value {
|
|
||||||
background-color: #ff6e00;
|
|
||||||
}
|
|
||||||
|
|
||||||
progress {
|
|
||||||
color: #ff6e00;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
top: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
|
@ -76,7 +48,6 @@ footer {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding-left: 5%;
|
padding-left: 5%;
|
||||||
padding-right: 5%;
|
padding-right: 5%;
|
||||||
outline: solid 2px #ff6e00;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
|
|
33
main.go
33
main.go
|
@ -1,20 +1,29 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed assets
|
// func getRoot(w http.ResponseWriter, r *http.Request) {
|
||||||
var assetsFolder embed.FS
|
// fmt.Printf("Received connection\n")
|
||||||
|
// file, err := os.Open("./index.html")
|
||||||
|
// if err != nil {
|
||||||
|
// log.Printf("Error happened opening index.html: %v\n", err)
|
||||||
|
// }
|
||||||
|
// defer file.Close()
|
||||||
|
// data, err := io.ReadAll(file)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Printf("Error happened reading data: %v\n", err)
|
||||||
|
// }
|
||||||
|
// fmt.Fprint(w, string(data))
|
||||||
|
// }
|
||||||
|
|
||||||
func uploadFile(w http.ResponseWriter, r *http.Request) {
|
func uploadFile(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintln(w, "Successful upload!")
|
fmt.Fprintln(w, "You have uploaded something")
|
||||||
|
|
||||||
file, header, err := r.FormFile("file")
|
file, header, err := r.FormFile("file")
|
||||||
|
|
||||||
|
@ -22,8 +31,6 @@ func uploadFile(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("Error happened receiving file: %v\n", err)
|
log.Printf("Error happened receiving file: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
_, err = os.Stat("./temp/")
|
_, err = os.Stat("./temp/")
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
os.Mkdir("./temp/", 0700)
|
os.Mkdir("./temp/", 0700)
|
||||||
|
@ -33,23 +40,19 @@ func uploadFile(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error happened opening file: %v\n", err)
|
log.Printf("Error happened opening file: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("[%v] Received file \"%v\" from %v\n", r.RemoteAddr, header.Filename, r.UserAgent())
|
log.Printf("[%v] Received file \"%v\" from %v\n", r.RemoteAddr, header.Filename, r.UserAgent())
|
||||||
io.Copy(f, file)
|
io.Copy(f, file)
|
||||||
|
|
||||||
|
defer file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
serverRoot, err := fs.Sub(assetsFolder, "assets")
|
http.Handle("/", http.FileServer(http.Dir("./assets")))
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error occurred setting HTML root: %v\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Handle("/", http.FileServer(http.FS(serverRoot)))
|
|
||||||
http.HandleFunc("/api/upload", uploadFile)
|
http.HandleFunc("/api/upload", uploadFile)
|
||||||
|
|
||||||
fmt.Println("Listening on port 8080...")
|
fmt.Println("Listening on port 8080...")
|
||||||
|
|
||||||
err = http.ListenAndServe(":8080", nil)
|
err := http.ListenAndServe(":8080", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue