Upload files to "/"

This commit is contained in:
mi.aliyan 2024-09-22 18:28:21 +00:00
commit 47085614d7
5 changed files with 67 additions and 0 deletions

1
COMMIT_EDITMSG Normal file
View File

@ -0,0 +1 @@
First commit

19
Dockerfile Normal file
View File

@ -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"]

10
config Normal file
View File

@ -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/*

1
description Normal file
View File

@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository.

36
hello.go Normal file
View File

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