Add starting files
This commit is contained in:
parent
cc9809f2c2
commit
bc91175e1c
|
@ -0,0 +1,17 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" type="" href="./style.css">
|
||||||
|
<script src="https://unpkg.com/htmx.org@1.9.4/dist/htmx.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p><b>Test</b></p>
|
||||||
|
<!-- <form action="/action_page.php"> -->
|
||||||
|
<!-- <input type="file" id="myFile" name="filename"> -->
|
||||||
|
<!-- <input type="submit"> -->
|
||||||
|
<form>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -0,0 +1,38 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getRoot(w http.ResponseWriter, r *http.Request) {
|
||||||
|
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) {
|
||||||
|
fmt.Printf("Received upload!\n")
|
||||||
|
fmt.Println(w, "You have uploaded something")
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
http.HandleFunc("/", getRoot)
|
||||||
|
http.HandleFunc("/api/upload", uploadFile)
|
||||||
|
|
||||||
|
err := http.ListenAndServe(":8080", nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue