Skip to content

Instantly share code, notes, and snippets.

@ernado
Created October 21, 2014 21:22
Show Gist options
  • Save ernado/c5395b8548beba5f7b01 to your computer and use it in GitHub Desktop.
Save ernado/c5395b8548beba5f7b01 to your computer and use it in GitHub Desktop.
# when uncommented gin.SetMode(gin.ReleaseMode)
ernado@node:/go/src/github.com/ernado/webrtc-chat$ ./webrtc-chat
[GIN] 2014/10/22 - 01:18:45 | 200 | 13.65133ms | 127.0.0.1:43140 GET /
[GIN] 2014/10/22 - 01:18:46 | 404 | 4.621us | 127.0.0.1:43146 GET /realtime
# when commended (in debug mode)
ernado@node:/go/src/github.com/ernado/webrtc-chat$ ./webrtc-chat
[GIN-debug] GET / --> main.func·002 (3 handlers)
[GIN-debug] GET /static/*filepath --> github.com/gin-gonic/gin.func·005 (3 handlers)
[GIN-debug] HEAD /static/*filepath --> github.com/gin-gonic/gin.func·006 (3 handlers)
[GIN-debug] Listening and serving HTTP on :8081
[GIN] 2014/10/22 - 01:19:04 | 500 | 22.24us | 127.0.0.1:43147 GET /
Error #01: open index.html: no such file or directory
Meta: [index.html <nil>]
package main
import (
"flag"
"fmt"
"github.com/gin-gonic/gin"
)
var (
port int
)
func init() {
flag.IntVar(&port, "port", 8081, "Port")
}
func main() {
flag.Parse()
router := gin.Default()
// gin.SetMode(gin.ReleaseMode)
router.LoadHTMLTemplates("static/*.html")
router.GET("/", func(c *gin.Context) {
c.HTML(200, "index.html", nil)
})
router.Static("/static", "static")
router.Run(fmt.Sprintf(":%d", port))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment