commit 47085614d75bbf47ea53f1a17a39e17dded64d27 Author: mi.aliyan Date: Sun Sep 22 18:28:21 2024 +0000 Upload files to "/" diff --git a/COMMIT_EDITMSG b/COMMIT_EDITMSG new file mode 100644 index 0000000..6eaf244 --- /dev/null +++ b/COMMIT_EDITMSG @@ -0,0 +1 @@ +First commit diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6cef195 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM golang:1.20-alpine as build + +WORKDIR /app + +COPY hello.go . + +RUN go build -o hello hello.go + +FROM alpine:3.16 + +WORKDIR /app + +COPY --from=build /app/hello . + +EXPOSE 8080 + +RUN chmod 755 hello + +CMD ["./hello"] \ No newline at end of file diff --git a/config b/config new file mode 100644 index 0000000..42e9cd5 --- /dev/null +++ b/config @@ -0,0 +1,10 @@ +[core] + repositoryformatversion = 0 + filemode = false + bare = false + logallrefupdates = true + symlinks = false + ignorecase = true +[remote "origin"] + url = https://gitea.workload.cam/mi.aliyan/simple-server.git + fetch = +refs/heads/*:refs/remotes/origin/* diff --git a/description b/description new file mode 100644 index 0000000..498b267 --- /dev/null +++ b/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/hello.go b/hello.go new file mode 100644 index 0000000..d04a666 --- /dev/null +++ b/hello.go @@ -0,0 +1,36 @@ +package main + +import ( + "fmt" // formatting and printing values to the console. + "log" // logging messages to the console. + "net/http" // Used for build HTTP servers and clients. +) + +// Port we listen on. +const portNum string = ":8080" + +// Handler functions. +func Home(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Homepage") +} + +func Info(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Info page") +} + +func main() { + log.Println("Starting our simple http server.") + + // Registering our handler functions, and creating paths. + http.HandleFunc("/", Home) + http.HandleFunc("/info", Info) + + log.Println("Started on port", portNum) + fmt.Println("To close connection CTRL+C :-)") + + // Spinning up the server. + err := http.ListenAndServe(portNum, nil) + if err != nil { + log.Fatal(err) + } +}