folder.go 625 B

12345678910111213141516171819202122232425262728
  1. package main
  2. import (
  3. "fmt"
  4. "net/http"
  5. )
  6. func createHandler(rw http.ResponseWriter, req *http.Request) {
  7. if req.Method == "GET" {
  8. fmt.Fprintf(rw, "You requested the create-file function.")
  9. } else {
  10. responseText := fmt.Sprintf("Method %s is not supported.", req.Method)
  11. http.Error(rw, responseText, http.StatusNotFound)
  12. return
  13. }
  14. }
  15. func main() {
  16. port := "8000"
  17. httpFileServer := http.FileServer(http.Dir("./files"))
  18. http.Handle("/", httpFileServer)
  19. fmt.Printf("Listening http://localhost:%s\n", port)
  20. if error := http.ListenAndServe(":"+port, nil); error != nil {
  21. fmt.Printf("Error: %s\n", error)
  22. }
  23. }