Skip to content

Instantly share code, notes, and snippets.

@salif
Last active September 16, 2020 13:43
Show Gist options
  • Save salif/098f4940059bbbe2dbdeb9f9b107c9b6 to your computer and use it in GitHub Desktop.
Save salif/098f4940059bbbe2dbdeb9f9b107c9b6 to your computer and use it in GitHub Desktop.
Simple HTTP Server (Golang)
package main
import (
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"os"
)
func main() {
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
r.Use(cors.Default())
r.Static("/", ".")
var port string = ":8080"
if len(os.Args) > 1 {
port = ":" + os.Args[1]
}
r.Run(port)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment