12345678910111213141516171819202122232425262728 |
- 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)
- }
- }
|