litpooh преди 3 години
ревизия
79478ddf15
променени са 5 файла, в които са добавени 49 реда и са изтрити 0 реда
  1. BIN
      .DS_Store
  2. BIN
      files/dog.jpeg
  3. 12 0
      files/index.html
  4. 9 0
      files/test.html
  5. 28 0
      folder.go

BIN
.DS_Store


BIN
files/dog.jpeg


+ 12 - 0
files/index.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Example</title>
+    </head>
+    <body>
+        <p>INDEX</p>
+    </body>
+    <form action="./create.html" method="get">
+        <input type="submit" value="Create a file">
+    </form>
+</html>

+ 9 - 0
files/test.html

@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Test</title>
+    </head>
+    <body>
+        <p>This is an example of a simple HTML page with one paragraph.</p>
+    </body>
+</html>

+ 28 - 0
folder.go

@@ -0,0 +1,28 @@
+package main
+
+import (
+	"fmt"
+	"net/http"
+)
+
+func createHandler(rw http.ResponseWriter, req *http.Request) {
+	if req.Method == "GET" {
+		fmt.Fprintf(rw, "You requested the create-file function.")
+
+	} else {
+		responseText := fmt.Sprintf("Method %s is not supported.", req.Method)
+		http.Error(rw, responseText, http.StatusNotFound)
+		return
+	}
+}
+
+func main() {
+	port := "8000"
+	httpFileServer := http.FileServer(http.Dir("./files"))
+	http.Handle("/", httpFileServer)
+
+	fmt.Printf("Listening http://localhost:%s\n", port)
+	if error := http.ListenAndServe(":"+port, nil); error != nil {
+		fmt.Printf("Error: %s\n", error)
+	}
+}